mcp-scraper 0.33.6 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/bin/api-server.cjs +13558 -12516
- package/dist/bin/api-server.cjs.map +1 -1
- package/dist/bin/api-server.js +3 -3
- package/dist/bin/mcp-scraper-cli.cjs +13 -2
- package/dist/bin/mcp-scraper-cli.cjs.map +1 -1
- package/dist/bin/mcp-scraper-cli.js +14 -4
- package/dist/bin/mcp-scraper-cli.js.map +1 -1
- package/dist/bin/mcp-scraper-install.cjs +2 -2
- package/dist/bin/mcp-scraper-install.cjs.map +1 -1
- package/dist/bin/mcp-scraper-install.js +2 -2
- package/dist/bin/mcp-stdio-server.cjs +117 -7
- package/dist/bin/mcp-stdio-server.cjs.map +1 -1
- package/dist/bin/mcp-stdio-server.js +7 -7
- package/dist/bin/paa-harvest.cjs +128 -13
- package/dist/bin/paa-harvest.cjs.map +1 -1
- package/dist/bin/paa-harvest.js +4 -4
- package/dist/{chunk-DUS4ENOY.js → chunk-2EDFOQD7.js} +2 -2
- package/dist/{chunk-DUS4ENOY.js.map → chunk-2EDFOQD7.js.map} +1 -1
- package/dist/{chunk-C2OD4ELT.js → chunk-3HBPKR5G.js} +2 -2
- package/dist/{chunk-A54ELKJK.js → chunk-4KQVIYIH.js} +139 -17
- package/dist/chunk-4KQVIYIH.js.map +1 -0
- package/dist/{chunk-AIK7WQD5.js → chunk-62DQAWPF.js} +141 -3
- package/dist/chunk-62DQAWPF.js.map +1 -0
- package/dist/{chunk-V73MPRU6.js → chunk-CB5C3BPB.js} +17 -1
- package/dist/chunk-CB5C3BPB.js.map +1 -0
- package/dist/{chunk-6ZUK4H66.js → chunk-J32XSMJI.js} +117 -8
- package/dist/chunk-J32XSMJI.js.map +1 -0
- package/dist/{chunk-LKIP7VDN.js → chunk-JBSGBSGT.js} +46 -3
- package/dist/chunk-JBSGBSGT.js.map +1 -0
- package/dist/chunk-NFMIHEYE.js +7 -0
- package/dist/chunk-NFMIHEYE.js.map +1 -0
- package/dist/{chunk-XL6YIWJ3.js → chunk-SUOHUXQS.js} +3 -3
- package/dist/{chunk-WJJTGRK4.js → chunk-V36LS5YV.js} +2 -2
- package/dist/{chunk-AT2PFWHW.js → chunk-ZID3WQID.js} +2 -2
- package/dist/{db-5SZQUI7A.js → db-YAI5AQOI.js} +16 -2
- package/dist/{extract-bundle-YNXTFCC3.js → extract-bundle-GPZRLBVY.js} +2 -2
- package/dist/index.cjs +128 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -4
- package/dist/{server-SHOYO52X.js → server-LKVPEQFE.js} +1386 -778
- package/dist/server-LKVPEQFE.js.map +1 -0
- package/dist/{site-extract-repository-ZDTO7ODZ.js → site-extract-repository-JHMVHENZ.js} +4 -4
- package/dist/{worker-BJ64GCDE.js → worker-ZZHSYI3Y.js} +7 -7
- package/docs/mcp-tool-manifest.generated.json +213 -3
- package/package.json +1 -1
- package/dist/chunk-6ZUK4H66.js.map +0 -1
- package/dist/chunk-A54ELKJK.js.map +0 -1
- package/dist/chunk-AIK7WQD5.js.map +0 -1
- package/dist/chunk-F65IIUHI.js +0 -7
- package/dist/chunk-F65IIUHI.js.map +0 -1
- package/dist/chunk-LKIP7VDN.js.map +0 -1
- package/dist/chunk-V73MPRU6.js.map +0 -1
- package/dist/server-SHOYO52X.js.map +0 -1
- /package/dist/{chunk-C2OD4ELT.js.map → chunk-3HBPKR5G.js.map} +0 -0
- /package/dist/{chunk-XL6YIWJ3.js.map → chunk-SUOHUXQS.js.map} +0 -0
- /package/dist/{chunk-WJJTGRK4.js.map → chunk-V36LS5YV.js.map} +0 -0
- /package/dist/{chunk-AT2PFWHW.js.map → chunk-ZID3WQID.js.map} +0 -0
- /package/dist/{db-5SZQUI7A.js.map → db-YAI5AQOI.js.map} +0 -0
- /package/dist/{extract-bundle-YNXTFCC3.js.map → extract-bundle-GPZRLBVY.js.map} +0 -0
- /package/dist/{site-extract-repository-ZDTO7ODZ.js.map → site-extract-repository-JHMVHENZ.js.map} +0 -0
- /package/dist/{worker-BJ64GCDE.js.map → worker-ZZHSYI3Y.js.map} +0 -0
|
@@ -372,16 +372,54 @@ var CREDIT_COST_CATALOG = [
|
|
|
372
372
|
}
|
|
373
373
|
];
|
|
374
374
|
var CONCURRENCY_PRICE_ID = "price_1Ta1NRS8aAcsk3TGwsRnYbix";
|
|
375
|
+
function tierBillingInterval(tier) {
|
|
376
|
+
return tier.billing_interval ?? "month";
|
|
377
|
+
}
|
|
378
|
+
function tierAmountChargedUsd(tier) {
|
|
379
|
+
return tier.billed_usd ?? tier.monthly_usd;
|
|
380
|
+
}
|
|
381
|
+
function tierCreditsPerInterval(tier) {
|
|
382
|
+
return tier.credits_mc / MC_PER_CREDIT;
|
|
383
|
+
}
|
|
375
384
|
var SUBSCRIPTION_TIERS = {
|
|
376
385
|
"price_1TmiHRS8aAcsk3TGwmSNfNIa": { tier: "starter", label: "Starter", price_id: "price_1TmiHRS8aAcsk3TGwmSNfNIa", monthly_usd: 12, credits_mc: 8e6, concurrency: 3, intro_coupon: "mcp-starter-1dollar-intro-12" },
|
|
377
386
|
"price_1TrgihS8aAcsk3TG5cglrq4D": { tier: "growth", label: "Growth", price_id: "price_1TrgihS8aAcsk3TG5cglrq4D", monthly_usd: 40, credits_mc: 26666700, concurrency: 10, intro_coupon: null },
|
|
378
387
|
"price_1TrgihS8aAcsk3TG4HnG4gbY": { tier: "scale", label: "Scale", price_id: "price_1TrgihS8aAcsk3TG4HnG4gbY", monthly_usd: 100, credits_mc: 8e7, concurrency: 20, intro_coupon: null },
|
|
379
|
-
"
|
|
380
|
-
"
|
|
388
|
+
"price_1TwqIVS8aAcsk3TG0FE3ddDM": { tier: "sonic", label: "Sonic Annual", price_id: "price_1TwqIVS8aAcsk3TG0FE3ddDM", monthly_usd: 25, billed_usd: 300, credits_mc: 25e7, concurrency: 3, intro_coupon: null, billing_interval: "year", credits_never_expire: true, private_offer: true },
|
|
389
|
+
"price_1TwqIWS8aAcsk3TGbGbtlLak": { tier: "sonic-memory", label: "Sonic Annual + Memory Pro", price_id: "price_1TwqIWS8aAcsk3TGbGbtlLak", monthly_usd: 34.5, billed_usd: 414, credits_mc: 25e7, concurrency: 3, intro_coupon: null, billing_interval: "year", credits_never_expire: true, includes_memory: true, private_offer: true }
|
|
381
390
|
};
|
|
382
391
|
var SUBSCRIPTION_TIER_BY_KEY = Object.fromEntries(
|
|
383
392
|
Object.values(SUBSCRIPTION_TIERS).map((t) => [t.tier, t])
|
|
384
393
|
);
|
|
394
|
+
var PRIVATE_OFFERS = {
|
|
395
|
+
sonic: {
|
|
396
|
+
slug: "sonic",
|
|
397
|
+
label: "Sonic annual partner offer",
|
|
398
|
+
headline: "A full year of MCP Scraper, with Credits that never expire.",
|
|
399
|
+
tier_keys: ["sonic", "sonic-memory"]
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
function offerClaimPathForTier(tierKey) {
|
|
403
|
+
const offer = Object.values(PRIVATE_OFFERS).find((o) => o.tier_keys.includes(tierKey));
|
|
404
|
+
return offer ? `/${offer.slug}/claim` : null;
|
|
405
|
+
}
|
|
406
|
+
function getPrivateOfferPayload(slug) {
|
|
407
|
+
const offer = PRIVATE_OFFERS[slug];
|
|
408
|
+
if (!offer) return null;
|
|
409
|
+
const options = offer.tier_keys.map((key) => SUBSCRIPTION_TIER_BY_KEY[key]).filter((t) => !!t).map((t) => ({
|
|
410
|
+
tier: t.tier,
|
|
411
|
+
label: t.label,
|
|
412
|
+
amount_usd: tierAmountChargedUsd(t),
|
|
413
|
+
interval: tierBillingInterval(t),
|
|
414
|
+
monthly_equivalent_usd: t.monthly_usd,
|
|
415
|
+
credits: tierCreditsPerInterval(t),
|
|
416
|
+
credits_never_expire: !!t.credits_never_expire,
|
|
417
|
+
includes_memory: !!t.includes_memory,
|
|
418
|
+
concurrency: t.concurrency
|
|
419
|
+
}));
|
|
420
|
+
if (!options.length) return null;
|
|
421
|
+
return { slug: offer.slug, label: offer.label, headline: offer.headline, options };
|
|
422
|
+
}
|
|
385
423
|
function getPublicRatesPayload() {
|
|
386
424
|
const starter = SUBSCRIPTION_TIER_BY_KEY.starter;
|
|
387
425
|
const costs = CREDIT_COST_CATALOG.map(({ aliases, ...cost }) => ({
|
|
@@ -537,8 +575,13 @@ export {
|
|
|
537
575
|
vendorCostUsdToMc,
|
|
538
576
|
CREDIT_COST_CATALOG,
|
|
539
577
|
CONCURRENCY_PRICE_ID,
|
|
578
|
+
tierBillingInterval,
|
|
579
|
+
tierAmountChargedUsd,
|
|
580
|
+
tierCreditsPerInterval,
|
|
540
581
|
SUBSCRIPTION_TIERS,
|
|
541
582
|
SUBSCRIPTION_TIER_BY_KEY,
|
|
583
|
+
offerClaimPathForTier,
|
|
584
|
+
getPrivateOfferPayload,
|
|
542
585
|
getPublicRatesPayload,
|
|
543
586
|
concurrencySlotBillingInfo,
|
|
544
587
|
mcToCredits,
|
|
@@ -553,4 +596,4 @@ export {
|
|
|
553
596
|
MEDIA_TRANSCRIBE_HOLD_MC,
|
|
554
597
|
MC_PER_USD
|
|
555
598
|
};
|
|
556
|
-
//# sourceMappingURL=chunk-
|
|
599
|
+
//# sourceMappingURL=chunk-JBSGBSGT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/api/rates.ts"],"sourcesContent":["export const MC_COSTS = {\n serp: 400,\n serp_headless: 400,\n serp_headful: 1_400,\n paa: 300,\n paa_base: 5_500,\n page_scrape: 100,\n url_map: 500,\n yt_channel: 200,\n yt_transcription: 200,\n fb_ad: 200,\n maps_search: 500,\n maps_place: 6_000,\n maps_review: 100,\n fb_search: 600,\n fb_transcribe: 33_300,\n google_ads_search: 600,\n google_ads_intel: 200,\n google_ads_transcribe: 33_300,\n instagram_profile: 400,\n instagram_media: 400,\n instagram_transcribe: 33_300,\n browser_minute: 12_000,\n reddit_thread: 3_000,\n reddit_comment: 200,\n video_analysis: 666_700,\n trustpilot_reviews: 500,\n trustpilot_review: 100,\n g2_reviews: 500,\n g2_review: 200,\n diff_page: 100,\n} as const\n\nexport type McCostKey = keyof typeof MC_COSTS\n\n/**\n * Kernel omits the `headless` field for a headful session, so the runtime\n * records headless as `true` and headful/unknown as `null`. Unknown is billed\n * at the conservative headful rate because no cheaper mode was proven.\n */\nexport function serpActualCostMc(headlessSent: boolean | null | undefined): number {\n return headlessSent === true ? MC_COSTS.serp_headless : MC_COSTS.serp_headful\n}\n\nexport const MC_PER_BROWSER_MS = MC_COSTS.browser_minute / 60_000\n\nexport function browserActiveCostMc(activeMs: number): number {\n return Math.round(activeMs * MC_PER_BROWSER_MS)\n}\n\nexport const BROWSER_OPEN_MIN_BALANCE_MC = 1_000\n\nexport const MC_PER_CREDIT = 100\n\n// Billing conversion is intentionally explicit rather than derived from a\n// Stripe plan. Plan grant changes must not silently reprice vendor-backed work.\nexport const BILLING_MC_PER_USD_NUMERATOR = 2_000_000\nexport const BILLING_MC_PER_USD_DENOMINATOR = 3\nexport const BILLING_BASIS_POINTS = 10_000\nexport const USD_NANOS = 1_000_000_000\n\nexport const SCHEDULED_RUN_BASE_CREDITS = 75\nexport const SCHEDULED_RUN_BASE_MC = SCHEDULED_RUN_BASE_CREDITS * MC_PER_CREDIT\nexport const SCHEDULED_AGENT_LLM_MARKUP_BPS = 15_000\nexport const SCHEDULED_AGENT_LLM_MARKUP = SCHEDULED_AGENT_LLM_MARKUP_BPS / BILLING_BASIS_POINTS\nexport const SCHEDULED_RUN_DEFAULT_MAX_CREDITS = 5_000\n\nexport const CONNECTED_USAGE_RATE_POLICY_VERSION = '2026-07-23.connected-usage-v2'\nexport const CONNECTED_ACTIVE_CONNECTION_MONTHLY_CREDITS = 15_000\nexport const CONNECTED_ACTIVE_CONNECTION_MONTHLY_MC = CONNECTED_ACTIVE_CONNECTION_MONTHLY_CREDITS * MC_PER_CREDIT\nexport const CONNECTED_FUNCTION_RUN_CREDITS = 2\nexport const CONNECTED_PROXY_REQUEST_CREDITS = 2\nexport const CONNECTED_COMPUTE_CREDITS_PER_SECOND = 5\nexport const CONNECTED_FUNCTION_RUN_MC = CONNECTED_FUNCTION_RUN_CREDITS * MC_PER_CREDIT\nexport const CONNECTED_PROXY_REQUEST_MC = CONNECTED_PROXY_REQUEST_CREDITS * MC_PER_CREDIT\nexport const CONNECTED_COMPUTE_MC_PER_SECOND = CONNECTED_COMPUTE_CREDITS_PER_SECOND * MC_PER_CREDIT\n\n/**\n * Versioned commercial contract for tenant-owned Nango connections.\n *\n * The recurring connection line item is denominated in USD and is deliberately\n * separate from usage debits in the Credit wallet. Usage receipts are reported\n * in aggregate milliseconds and rounded once to the smallest ledger unit (mc),\n * never up to a whole compute second.\n */\nexport const CONNECTED_USAGE_RATE_POLICY = {\n schemaVersion: 2,\n ratePolicyVersion: CONNECTED_USAGE_RATE_POLICY_VERSION,\n effectiveAt: '2026-07-23T00:00:00.000Z',\n provider: 'nango',\n entitlement: 'paid_plan_add_on',\n connection: {\n billingMode: 'flat_recurring_credits',\n amountCredits: CONNECTED_ACTIVE_CONNECTION_MONTHLY_CREDITS,\n interval: 'month',\n unit: 'active_connection',\n proration: 'none',\n },\n usage: {\n billingMode: 'credits',\n settlementMode: 'authoritative_receipt',\n rounding: 'aggregate_then_ceil_to_mc',\n functionRun: {\n credits: CONNECTED_FUNCTION_RUN_CREDITS,\n mc: CONNECTED_FUNCTION_RUN_MC,\n unit: 'per_function_run',\n },\n proxyRequest: {\n credits: CONNECTED_PROXY_REQUEST_CREDITS,\n mc: CONNECTED_PROXY_REQUEST_MC,\n unit: 'per_proxy_request',\n },\n compute: {\n creditsPerSecond: CONNECTED_COMPUTE_CREDITS_PER_SECOND,\n mcPerSecond: CONNECTED_COMPUTE_MC_PER_SECOND,\n sourceUnit: 'millisecond',\n unit: 'per_compute_second',\n formula: 'ceil(computeMilliseconds * mcPerSecond / 1000)',\n },\n },\n} as const\n\nexport interface ConnectedUsageQuantities {\n functionRuns: number\n proxyRequests: number\n computeMilliseconds: number\n}\n\nexport interface ConnectedUsageCharge {\n functionRunMc: number\n proxyRequestMc: number\n computeMc: number\n amountMc: number\n credits: number\n}\n\nfunction nonNegativeSafeInteger(value: number, field: string): bigint {\n if (!Number.isSafeInteger(value) || value < 0) {\n throw new Error(`${field} must be a non-negative safe integer`)\n }\n return BigInt(value)\n}\n\nfunction safeMc(value: bigint): number {\n if (value > BigInt(Number.MAX_SAFE_INTEGER)) throw new Error('connected usage charge exceeds the safe integer range')\n return Number(value)\n}\n\n/** Calculate one receipt after aggregating its raw Nango usage counters. */\nexport function calculateConnectedUsageCharge(usage: ConnectedUsageQuantities): ConnectedUsageCharge {\n const functionRuns = nonNegativeSafeInteger(usage.functionRuns, 'functionRuns')\n const proxyRequests = nonNegativeSafeInteger(usage.proxyRequests, 'proxyRequests')\n const computeMilliseconds = nonNegativeSafeInteger(usage.computeMilliseconds, 'computeMilliseconds')\n const functionRunMc = functionRuns * BigInt(CONNECTED_FUNCTION_RUN_MC)\n const proxyRequestMc = proxyRequests * BigInt(CONNECTED_PROXY_REQUEST_MC)\n const computeNumerator = computeMilliseconds * BigInt(CONNECTED_COMPUTE_MC_PER_SECOND)\n const computeMc = computeNumerator === 0n ? 0n : (computeNumerator + 999n) / 1_000n\n const amountMc = functionRunMc + proxyRequestMc + computeMc\n\n return {\n functionRunMc: safeMc(functionRunMc),\n proxyRequestMc: safeMc(proxyRequestMc),\n computeMc: safeMc(computeMc),\n amountMc: safeMc(amountMc),\n credits: safeMc(amountMc) / MC_PER_CREDIT,\n }\n}\n\n/**\n * Public, machine-readable Scheduled Actions billing contract.\n *\n * Keep every API/UI surface on this object instead of restating the policy.\n * The primitive constants above remain the execution-time source of truth;\n * this object gives clients stable semantic fields for displaying and applying\n * those rates without having to infer behavior from prose.\n */\nexport const SCHEDULED_ACTIONS_RATE_POLICY = {\n billingMode: 'credits',\n entitlement: 'paid_plan_included',\n separateSubscriptionRequired: false,\n chargeEvent: 'started_occurrence',\n runBaseCredits: SCHEDULED_RUN_BASE_CREDITS,\n runBaseMc: SCHEDULED_RUN_BASE_MC,\n llmCostMultiplier: SCHEDULED_AGENT_LLM_MARKUP,\n llmCostMultiplierBps: SCHEDULED_AGENT_LLM_MARKUP_BPS,\n modes: {\n connection_sync: {\n runBaseCredits: SCHEDULED_RUN_BASE_CREDITS,\n modelCostBilling: 'none',\n modelCostMultiplier: 0,\n },\n agent: {\n runBaseCredits: SCHEDULED_RUN_BASE_CREDITS,\n modelCostBilling: 'actual_reported_cost',\n modelCostProvider: 'openrouter',\n modelCostMultiplier: SCHEDULED_AGENT_LLM_MARKUP,\n modelCostMultiplierBps: SCHEDULED_AGENT_LLM_MARKUP_BPS,\n },\n },\n} as const\n\nexport function vendorCostUsdToMc(costUsd: number, markupBps: number): number {\n if (!Number.isFinite(costUsd) || costUsd < 0) throw new Error('costUsd must be a finite non-negative number')\n if (!Number.isInteger(markupBps) || markupBps < 0) throw new Error('markupBps must be a non-negative integer')\n\n const rawCostNanos = BigInt(Math.round(costUsd * USD_NANOS))\n const numerator =\n rawCostNanos *\n BigInt(markupBps) *\n BigInt(BILLING_MC_PER_USD_NUMERATOR)\n const denominator =\n BigInt(USD_NANOS) *\n BigInt(BILLING_BASIS_POINTS) *\n BigInt(BILLING_MC_PER_USD_DENOMINATOR)\n const mc = numerator === 0n ? 0n : (numerator + denominator - 1n) / denominator\n if (mc > BigInt(Number.MAX_SAFE_INTEGER)) throw new Error('calculated mc exceeds the safe integer range')\n return Number(mc)\n}\n\nexport const CREDIT_COST_CATALOG: Array<{\n key: McCostKey\n label: string\n aliases: string[]\n credits: number\n unit: string\n notes?: string\n}> = [\n {\n key: 'serp',\n label: 'SERP search',\n aliases: ['search_serp', 'serp', 'google search', 'organic results'],\n credits: mcToCredits(MC_COSTS.serp_headless),\n unit: 'per search (headless); escalates to headful only when needed',\n notes: `Returns AI Overview, PAA snippet, videos, forums, and local pack. Billed ${mcToCredits(MC_COSTS.serp_headless)} credits when served headless (the common case), ${mcToCredits(MC_COSTS.serp_headful)} credits if an anti-bot escalation forces headful mode (overestimate refunded). Optional SERP Intelligence page snapshots add ${mcToCredits(MC_COSTS.page_scrape)} credit per attempted URL.`,\n },\n {\n key: 'paa',\n label: 'PAA harvest',\n aliases: ['harvest_paa', 'paa', 'people also ask', 'questions'],\n credits: mcToCredits(MC_COSTS.paa),\n unit: `per question (+${mcToCredits(MC_COSTS.paa_base)} credit base)`,\n notes: `Full SERP feature extraction. Billed ${mcToCredits(MC_COSTS.paa_base)} credit base + ${mcToCredits(MC_COSTS.paa)} per question actually returned (unused estimate refunded).`,\n },\n {\n key: 'page_scrape',\n label: 'Page crawl / extract',\n aliases: ['extract_url', 'extract_site', 'page scrape', 'url scrape', 'single page', 'site crawl'],\n credits: mcToCredits(MC_COSTS.page_scrape),\n unit: 'per page',\n notes: 'Applies to both single-URL extraction and per-page site crawls.',\n },\n {\n key: 'url_map',\n label: 'Site URL mapping',\n aliases: ['map_site_urls', 'url map', 'site map', 'crawl urls'],\n credits: mcToCredits(MC_COSTS.url_map),\n unit: 'per mapping operation',\n notes: 'Flat rate for the full /map-urls call regardless of URL count discovered.',\n },\n {\n key: 'yt_channel',\n label: 'YouTube search / channel harvest',\n aliases: ['youtube_harvest', 'youtube search', 'youtube channel', 'yt_channel'],\n credits: mcToCredits(MC_COSTS.yt_channel),\n unit: 'per call',\n },\n {\n key: 'yt_transcription',\n label: 'YouTube transcription',\n aliases: ['youtube_transcribe', 'youtube transcript', 'transcription', 'yt_transcription'],\n credits: mcToCredits(MC_COSTS.yt_transcription),\n unit: 'per minute',\n notes: 'A 5-minute hold is taken, then reconciled to actual video duration.',\n },\n {\n key: 'fb_ad',\n label: 'Facebook search / ad lookup',\n aliases: ['facebook_page_intel', 'facebook_ad_search', 'facebook_ad', 'facebook ads', 'fb ads'],\n credits: mcToCredits(MC_COSTS.fb_ad),\n unit: 'per call',\n },\n {\n key: 'maps_search',\n label: 'Maps business search',\n aliases: ['maps_search', 'google maps search', 'gmb search', 'gbp search', 'business profiles'],\n credits: mcToCredits(MC_COSTS.maps_search),\n unit: 'per search',\n notes: 'Returns up to 50 Google Maps business/profile candidates. Use maps_place_intel to hydrate selected businesses.',\n },\n {\n key: 'maps_place',\n label: 'Maps business lookup',\n aliases: ['maps_place_intel', 'google maps', 'maps place', 'place intel'],\n credits: mcToCredits(MC_COSTS.maps_place),\n unit: 'per business',\n notes: 'Base lookup. Reviews billed separately per card at maps_review rate.',\n },\n {\n key: 'maps_review',\n label: 'Maps review',\n aliases: ['maps_reviews', 'google reviews', 'review cards', 'reviews'],\n credits: mcToCredits(MC_COSTS.maps_review),\n unit: 'per review card',\n notes: 'Charged after extraction when includeReviews is true.',\n },\n {\n key: 'fb_search',\n label: 'Facebook ad library search',\n aliases: ['facebook_search', 'fb_search', 'fb ad search'],\n credits: mcToCredits(MC_COSTS.fb_search),\n unit: 'per search',\n notes: 'Browser automation to search Facebook Ads Library by keyword.',\n },\n {\n key: 'google_ads_search',\n label: 'Google Ads Transparency search',\n aliases: ['google_ads_search', 'google ads search', 'ads transparency search'],\n credits: mcToCredits(MC_COSTS.google_ads_search),\n unit: 'per search',\n notes: 'Browser automation to find advertisers in Google Ads Transparency Center by domain or name.',\n },\n {\n key: 'google_ads_intel',\n label: 'Google Ads Transparency advertiser intel',\n aliases: ['google_ads_page_intel', 'google ads intel', 'ads transparency intel'],\n credits: mcToCredits(MC_COSTS.google_ads_intel),\n unit: 'per call',\n notes: 'Lists and hydrates an advertiser\\'s creatives with image URLs and video references.',\n },\n {\n key: 'google_ads_transcribe',\n label: 'Google ad video transcription',\n aliases: ['google_ads_transcribe', 'google ad transcript'],\n credits: mcToCredits(MC_COSTS.google_ads_transcribe),\n unit: 'per minute (typical)',\n notes: 'A hold is taken, then reconciled to the real transcription cost for the actual audio duration.',\n },\n {\n key: 'fb_transcribe',\n label: 'Facebook video / ad transcription',\n aliases: ['facebook_transcribe', 'facebook_video_transcribe', 'fb_transcribe', 'fb ad transcript'],\n credits: mcToCredits(MC_COSTS.fb_transcribe),\n unit: 'per minute (typical)',\n notes: 'A hold is taken, then reconciled to the real transcription cost for the actual audio duration.',\n },\n {\n key: 'instagram_profile',\n label: 'Instagram profile content discovery',\n aliases: ['instagram_profile_content', 'instagram profile', 'instagram content list', 'ig profile'],\n credits: mcToCredits(MC_COSTS.instagram_profile),\n unit: 'per profile scan',\n notes: 'Browser extraction of public Instagram profile grid links. Complete history may require a logged-in profile.',\n },\n {\n key: 'instagram_media',\n label: 'Instagram media download',\n aliases: ['instagram_media_download', 'instagram reel download', 'instagram post download', 'ig media'],\n credits: mcToCredits(MC_COSTS.instagram_media),\n unit: 'per post or reel',\n notes: 'Extracts post text, image URLs, and reel audio/video tracks, with local downloads when the server can write files.',\n },\n {\n key: 'instagram_transcribe',\n label: 'Instagram media transcription',\n aliases: ['instagram transcript', 'instagram reel transcript', 'ig transcribe'],\n credits: mcToCredits(MC_COSTS.instagram_transcribe),\n unit: 'per minute (typical)',\n notes: 'Whisper transcription of selected Instagram audio/video media via fal.ai. A hold is taken, then reconciled to the real transcription cost for the actual audio duration.',\n },\n {\n key: 'browser_minute',\n label: 'Interactive browser session',\n aliases: ['browser_open', 'browser agent', 'browser_agent', 'live browser', 'browse', 'browser control', 'interactive browser'],\n credits: mcToCredits(MC_COSTS.browser_minute),\n unit: 'per minute of use',\n notes: 'Metered per minute of use for the whole time the browser session is open. Close the session to stop the meter; abandoned sessions are auto-closed after a short idle window.',\n },\n {\n key: 'reddit_thread',\n label: 'Reddit thread base lookup',\n aliases: ['reddit', 'reddit_thread', 'reddit comments', 'subreddit', 'reddit post'],\n credits: mcToCredits(MC_COSTS.reddit_thread),\n unit: 'per thread',\n notes: 'Base lookup for the post itself. Comments billed separately per comment at reddit_comment rate. Refunded if the thread cannot be retrieved.',\n },\n {\n key: 'reddit_comment',\n label: 'Reddit comment',\n aliases: ['reddit_comment', 'reddit comments'],\n credits: mcToCredits(MC_COSTS.reddit_comment),\n unit: 'per comment',\n notes: 'Charged per comment actually extracted, billed down automatically if the balance runs out mid-thread.',\n },\n {\n key: 'video_analysis',\n label: 'Video breakdown (frame-by-frame + transcript)',\n aliases: ['video_frame_analysis', 'video breakdown', 'video analysis', 'analyze video'],\n credits: mcToCredits(MC_COSTS.video_analysis),\n unit: 'per 120 frames (max 480)',\n notes: 'Full multi-lens video breakdown: samples frames across a video (up to 30 minutes), analyzes each with vision AI, transcribes the audio, then produces summary, pacing/energy, words-per-minute, topic outline, key points, hook analysis, visual style, and a how-to-replicate recipe with a quality-control pass. $1 per 120 frames requested (max 480 = $4); billed down automatically if the video cannot use the requested frames, and refunded fully if the run fails.',\n },\n {\n key: 'trustpilot_reviews',\n label: 'Trustpilot review harvest',\n aliases: ['trustpilot_reviews', 'trustpilot', 'trustpilot reviews'],\n credits: mcToCredits(MC_COSTS.trustpilot_reviews),\n unit: 'per call',\n notes: 'Base lookup. Reviews billed separately per card at trustpilot_review rate. Refunded if no reviews are found.',\n },\n {\n key: 'trustpilot_review',\n label: 'Trustpilot review card',\n aliases: ['trustpilot_review', 'trustpilot card'],\n credits: mcToCredits(MC_COSTS.trustpilot_review),\n unit: 'per review card',\n notes: 'Charged per review actually extracted, billed down automatically if the balance runs out mid-page.',\n },\n {\n key: 'g2_reviews',\n label: 'G2 review harvest',\n aliases: ['g2_reviews', 'g2', 'g2 reviews'],\n credits: mcToCredits(MC_COSTS.g2_reviews),\n unit: 'per call',\n notes: 'Base lookup. Reviews billed separately per card at g2_review rate. Refunded if no reviews are found.',\n },\n {\n key: 'g2_review',\n label: 'G2 review card',\n aliases: ['g2_review', 'g2 card'],\n credits: mcToCredits(MC_COSTS.g2_review),\n unit: 'per review card',\n notes: 'Charged per review actually extracted (each card carries up to 3 Q&A sections), billed down automatically if the balance runs out mid-page.',\n },\n {\n key: 'diff_page',\n label: 'Page change check',\n aliases: ['diff_page', 'page diff', 'change detection'],\n credits: mcToCredits(MC_COSTS.diff_page),\n unit: 'per check',\n notes: 'Same cost as a single page extract — one scrape is performed per check, then compared against your last stored snapshot for that URL.',\n },\n]\n\nexport const CONCURRENCY_PRICE_ID = 'price_1Ta1NRS8aAcsk3TGwsRnYbix'\n\nexport interface SubscriptionTier {\n tier: string\n label: string\n price_id: string\n monthly_usd: number\n billed_usd?: number\n credits_mc: number\n concurrency: number\n intro_coupon: string | null\n billing_interval?: 'month' | 'year'\n credits_never_expire?: boolean\n includes_memory?: boolean\n private_offer?: boolean\n}\n\nexport function tierBillingInterval(tier: SubscriptionTier): 'month' | 'year' {\n return tier.billing_interval ?? 'month'\n}\n\nexport function tierAmountChargedUsd(tier: SubscriptionTier): number {\n return tier.billed_usd ?? tier.monthly_usd\n}\n\nexport function tierCreditsPerInterval(tier: SubscriptionTier): number {\n return tier.credits_mc / MC_PER_CREDIT\n}\n\nexport const SUBSCRIPTION_TIERS: Record<string, SubscriptionTier> = {\n 'price_1TmiHRS8aAcsk3TGwmSNfNIa': { tier: 'starter', label: 'Starter', price_id: 'price_1TmiHRS8aAcsk3TGwmSNfNIa', monthly_usd: 12, credits_mc: 8_000_000, concurrency: 3, intro_coupon: 'mcp-starter-1dollar-intro-12' },\n 'price_1TrgihS8aAcsk3TG5cglrq4D': { tier: 'growth', label: 'Growth', price_id: 'price_1TrgihS8aAcsk3TG5cglrq4D', monthly_usd: 40, credits_mc: 26_666_700, concurrency: 10, intro_coupon: null },\n 'price_1TrgihS8aAcsk3TG4HnG4gbY': { tier: 'scale', label: 'Scale', price_id: 'price_1TrgihS8aAcsk3TG4HnG4gbY', monthly_usd: 100, credits_mc: 80_000_000, concurrency: 20, intro_coupon: null },\n 'price_1TwqIVS8aAcsk3TG0FE3ddDM': { tier: 'sonic', label: 'Sonic Annual', price_id: 'price_1TwqIVS8aAcsk3TG0FE3ddDM', monthly_usd: 25, billed_usd: 300, credits_mc: 250_000_000, concurrency: 3, intro_coupon: null, billing_interval: 'year', credits_never_expire: true, private_offer: true },\n 'price_1TwqIWS8aAcsk3TGbGbtlLak': { tier: 'sonic-memory', label: 'Sonic Annual + Memory Pro', price_id: 'price_1TwqIWS8aAcsk3TGbGbtlLak', monthly_usd: 34.5, billed_usd: 414, credits_mc: 250_000_000, concurrency: 3, intro_coupon: null, billing_interval: 'year', credits_never_expire: true, includes_memory: true, private_offer: true },\n}\n\nexport const SUBSCRIPTION_TIER_BY_KEY: Record<string, SubscriptionTier> = Object.fromEntries(\n Object.values(SUBSCRIPTION_TIERS).map(t => [t.tier, t]),\n)\n\nexport interface PrivateOffer {\n slug: string\n label: string\n headline: string\n tier_keys: string[]\n}\n\nexport const PRIVATE_OFFERS: Record<string, PrivateOffer> = {\n sonic: {\n slug: 'sonic',\n label: 'Sonic annual partner offer',\n headline: 'A full year of MCP Scraper, with Credits that never expire.',\n tier_keys: ['sonic', 'sonic-memory'],\n },\n}\n\nexport function offerClaimPathForTier(tierKey: string): string | null {\n const offer = Object.values(PRIVATE_OFFERS).find(o => o.tier_keys.includes(tierKey))\n return offer ? `/${offer.slug}/claim` : null\n}\n\nexport function getPrivateOfferPayload(slug: string) {\n const offer = PRIVATE_OFFERS[slug]\n if (!offer) return null\n const options = offer.tier_keys\n .map(key => SUBSCRIPTION_TIER_BY_KEY[key])\n .filter((t): t is SubscriptionTier => !!t)\n .map(t => ({\n tier: t.tier,\n label: t.label,\n amount_usd: tierAmountChargedUsd(t),\n interval: tierBillingInterval(t),\n monthly_equivalent_usd: t.monthly_usd,\n credits: tierCreditsPerInterval(t),\n credits_never_expire: !!t.credits_never_expire,\n includes_memory: !!t.includes_memory,\n concurrency: t.concurrency,\n }))\n if (!options.length) return null\n return { slug: offer.slug, label: offer.label, headline: offer.headline, options }\n}\n\nexport function getPublicRatesPayload() {\n const starter = SUBSCRIPTION_TIER_BY_KEY.starter\n const costs = CREDIT_COST_CATALOG.map(({ aliases, ...cost }) => ({\n ...cost,\n ...(cost.notes ? { notes: cost.notes.replace(/ via fal\\.ai/g, '') } : {}),\n }))\n\n return {\n creditsPerDollarStarter: Math.round(mcToCredits(starter.credits_mc) / starter.monthly_usd),\n costs,\n scheduling: SCHEDULED_ACTIONS_RATE_POLICY,\n connectedAccounts: CONNECTED_USAGE_RATE_POLICY,\n }\n}\n\nexport const CONCURRENCY_SLOT_PRICE_USD = 5\nexport const CONCURRENCY_SLOT_PRICE_CURRENCY = 'usd'\nexport const CONCURRENCY_SLOT_PRICE_INTERVAL = 'month'\nexport const CONCURRENCY_SLOT_PRICE_LABEL = '$5/month'\nexport const CONCURRENCY_SLOT_TERMINAL_COMMAND = 'npx -y -p mcp-scraper@latest mcp-scraper-cli billing concurrency checkout'\n\nexport function concurrencySlotBillingInfo() {\n const billingUrl = process.env.CONCURRENCY_BILLING_URL ?? 'https://mcpscraper.dev/billing'\n return {\n product: 'Extra concurrency slot',\n price_label: CONCURRENCY_SLOT_PRICE_LABEL,\n unit_amount_usd: CONCURRENCY_SLOT_PRICE_USD,\n currency: CONCURRENCY_SLOT_PRICE_CURRENCY,\n interval: CONCURRENCY_SLOT_PRICE_INTERVAL,\n billing_url: billingUrl,\n terminal_command: CONCURRENCY_SLOT_TERMINAL_COMMAND,\n terminal_command_with_api_key_env: `MCP_SCRAPER_API_KEY=sk_live_your_key ${CONCURRENCY_SLOT_TERMINAL_COMMAND}`,\n }\n}\n\n// The free tier is retired. Keep these exported compatibility constants at zero\n// so older consumers do not advertise or grant credits that no longer exist.\nexport const FREE_SIGNUP_MC = 0\nexport const FREE_MONTHLY_REFRESH_MC = 0\n\nexport const BALANCE_PRICE_IDS: Record<string, number> = {\n 'price_1TZx6rS8aAcsk3TGNMc1Vgpo': 11_000_000,\n 'price_1TZx6sS8aAcsk3TGxgqB7khO': 27_500_000,\n 'price_1TZx6tS8aAcsk3TG8PnJqHlG': 60_500_000,\n 'price_1TZx6tS8aAcsk3TGNgRMpy0e': 121_000_000,\n}\n\nexport const BALANCE_PACK_LABELS: Record<string, string> = {\n 'price_1TZx6rS8aAcsk3TGNMc1Vgpo': '$10',\n 'price_1TZx6sS8aAcsk3TGxgqB7khO': '$25',\n 'price_1TZx6tS8aAcsk3TG8PnJqHlG': '$50',\n 'price_1TZx6tS8aAcsk3TGNgRMpy0e': '$100',\n}\n\nexport function mcToCredits(mc: number): number {\n return mc / MC_PER_CREDIT\n}\n\nexport function insufficientBalanceResponse(balanceMc: number, requiredMc: number) {\n const topupUrl = process.env.TOPUP_URL ?? 'https://mcpscraper.dev/billing'\n const balanceCredits = mcToCredits(balanceMc)\n const requiredCredits = mcToCredits(requiredMc)\n return {\n error: 'insufficient_balance',\n error_code: 'insufficient_balance' as const,\n message: `Insufficient credits. Balance: ${balanceCredits} credits. This call requires ${requiredCredits} credits. Top up at ${topupUrl}`,\n balance_credits: balanceCredits,\n required_credits: requiredCredits,\n topup_url: topupUrl,\n }\n}\n\nexport interface MemoryPlan {\n plan: 'pro' | 'team'\n label: string\n price_id: string\n interval: 'month' | 'year'\n monthly_usd: number\n quota_bytes: number\n}\n\nexport const MEMORY_FREE_QUOTA_BYTES = 0.01e9 * 1\n\nexport const MEMORY_PLANS: Record<string, MemoryPlan> = {\n 'price_1TnMSTS8aAcsk3TGBgiwuvqL': { plan: 'pro', label: 'Pro', price_id: 'price_1TnMSTS8aAcsk3TGBgiwuvqL', interval: 'month', monthly_usd: 19, quota_bytes: 5e9 },\n 'price_1TnMSTS8aAcsk3TGWBVU2agY': { plan: 'pro', label: 'Pro', price_id: 'price_1TnMSTS8aAcsk3TGWBVU2agY', interval: 'year', monthly_usd: 19, quota_bytes: 5e9 },\n}\n\nexport const MEMORY_PLAN_QUOTA: Record<string, number> = { free: MEMORY_FREE_QUOTA_BYTES, pro: 5e9, team: 50e9 }\n\nexport const MEMORY_MARGIN_MULTIPLE = 3\nexport const MEMORY_FREE_COST_CAP_USD = 1.0\nexport const MEMORY_PRO_COST_BUDGET_USD = 19 / MEMORY_MARGIN_MULTIPLE\n\nexport const LedgerOperation = {\n TOPUP: 'topup',\n SUBSCRIPTION: 'subscription',\n SIGNUP_GRANT: 'signup_grant',\n MONTHLY_REFRESH: 'monthly_free_refresh',\n PAA: 'paa',\n PAA_REFUND: 'paa_refund',\n SERP: 'serp',\n SERP_REFUND: 'serp_refund',\n REFUND: 'refund',\n TRANSCRIPTION: 'transcription',\n TRANSCRIPTION_HOLD: 'transcription_hold',\n TRANSCRIPTION_REFUND: 'transcription_refund',\n YT_CHANNEL: 'yt_channel',\n FB_AD: 'fb_ad',\n MAPS_SEARCH: 'maps_search',\n MAPS_PLACE: 'maps_place',\n MAPS_REVIEW: 'maps_review',\n MAPS_REVIEW_REFUND: 'maps_review_refund',\n EXTRACT_SITE: 'extract_site',\n EXTRACT_SITE_REFUND: 'extract_site_refund',\n EXTRACT_URL: 'page_scrape',\n URL_MAP: 'url_map',\n EXTRACT_SITE_HOLD: 'extract_site_hold',\n YT_CHANNEL_REFUND: 'yt_channel_refund',\n FB_AD_REFUND: 'fb_ad_refund',\n URL_MAP_REFUND: 'url_map_refund',\n FB_SEARCH: 'fb_search',\n FB_TRANSCRIBE: 'fb_transcribe',\n FB_SEARCH_REFUND: 'fb_search_refund',\n FB_TRANSCRIBE_REFUND: 'fb_transcribe_refund',\n GOOGLE_ADS_SEARCH: 'google_ads_search',\n GOOGLE_ADS_SEARCH_REFUND: 'google_ads_search_refund',\n GOOGLE_ADS_INTEL: 'google_ads_intel',\n GOOGLE_ADS_INTEL_REFUND: 'google_ads_intel_refund',\n GOOGLE_ADS_TRANSCRIBE: 'google_ads_transcribe',\n GOOGLE_ADS_TRANSCRIBE_REFUND: 'google_ads_transcribe_refund',\n INSTAGRAM_PROFILE: 'instagram_profile',\n INSTAGRAM_PROFILE_REFUND: 'instagram_profile_refund',\n INSTAGRAM_MEDIA: 'instagram_media',\n INSTAGRAM_MEDIA_REFUND:'instagram_media_refund',\n INSTAGRAM_TRANSCRIBE: 'instagram_transcribe',\n INSTAGRAM_TRANSCRIBE_REFUND: 'instagram_transcribe_refund',\n BROWSER_SESSION: 'browser_session',\n REDDIT_THREAD: 'reddit_thread',\n REDDIT_THREAD_REFUND: 'reddit_thread_refund',\n REDDIT_COMMENT: 'reddit_comment',\n REDDIT_COMMENT_REFUND: 'reddit_comment_refund',\n VIDEO_ANALYSIS: 'video_analysis',\n VIDEO_ANALYSIS_REFUND: 'video_analysis_refund',\n VIDEO_ANALYSIS_ADJUST: 'video_analysis_adjust',\n VIDEO_ANALYSIS_LLM: 'video_analysis_llm',\n MEMORY_AI: 'memory_ai',\n MEMORY_AI_REFUND: 'memory_ai_refund',\n TRUSTPILOT_REVIEWS: 'trustpilot_reviews',\n TRUSTPILOT_REVIEWS_REFUND: 'trustpilot_reviews_refund',\n TRUSTPILOT_REVIEW: 'trustpilot_review',\n TRUSTPILOT_REVIEW_REFUND: 'trustpilot_review_refund',\n G2_REVIEWS: 'g2_reviews',\n G2_REVIEWS_REFUND: 'g2_reviews_refund',\n G2_REVIEW: 'g2_review',\n G2_REVIEW_REFUND: 'g2_review_refund',\n DIFF_PAGE: 'diff_page',\n DIFF_PAGE_REFUND: 'diff_page_refund',\n SITE_AUDIT_LLM: 'site_audit_llm',\n SCHEDULED_RUN: 'scheduled_run',\n CONNECTED_USAGE: 'connected_usage',\n CONNECTED_ACCOUNT_FEE: 'connected_account_fee',\n} as const\n\nexport type LedgerOperation = typeof LedgerOperation[keyof typeof LedgerOperation]\n\nexport const MEMORY_AI_MARGIN_MULTIPLE = 3\nexport const SITE_AUDIT_LLM_MARGIN_MULTIPLE = 1.5\nexport const VIDEO_ANALYSIS_LLM_MARGIN_MULTIPLE = 1.5\nexport const MEDIA_TRANSCRIBE_MARGIN_MULTIPLE = 3\nexport const MEDIA_TRANSCRIBE_HOLD_MC = MC_COSTS.fb_transcribe * 3\n\nexport const MC_PER_USD =\n SUBSCRIPTION_TIERS['price_1TmiHRS8aAcsk3TGwmSNfNIa'].credits_mc /\n SUBSCRIPTION_TIERS['price_1TmiHRS8aAcsk3TGwmSNfNIa'].monthly_usd\n"],"mappings":";AAAO,IAAM,WAAW;AAAA,EACtB,MAAmB;AAAA,E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;AAIO,IAAM,4BAA4B;AAClC,IAAM,iCAAiC;AACvC,IAAM,qCAAqC;AAC3C,IAAM,mCAAmC;AACzC,IAAM,2BAA2B,SAAS,gBAAgB;AAE1D,IAAM,aACX,mBAAmB,gCAAgC,EAAE,aACrD,mBAAmB,gCAAgC,EAAE;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/version.ts"],"sourcesContent":["export const PACKAGE_VERSION = '0.34.0'\n"],"mappings":";AAAO,IAAM,kBAAkB;","names":[]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LedgerOperation
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JBSGBSGT.js";
|
|
4
4
|
import {
|
|
5
5
|
sanitizeVendorName
|
|
6
6
|
} from "./chunk-M2S27J6Z.js";
|
|
7
7
|
import {
|
|
8
8
|
getDb
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-62DQAWPF.js";
|
|
10
10
|
|
|
11
11
|
// src/api/site-extract-repository.ts
|
|
12
12
|
function rowToJob(r) {
|
|
@@ -127,4 +127,4 @@ export {
|
|
|
127
127
|
failExtractJob,
|
|
128
128
|
settleExtractJob
|
|
129
129
|
};
|
|
130
|
-
//# sourceMappingURL=chunk-
|
|
130
|
+
//# sourceMappingURL=chunk-SUOHUXQS.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getDb
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-62DQAWPF.js";
|
|
4
4
|
|
|
5
5
|
// src/lib/browser-service-env.ts
|
|
6
6
|
function browserServiceApiKey() {
|
|
@@ -258,4 +258,4 @@ export {
|
|
|
258
258
|
recordKernelSession,
|
|
259
259
|
recordVendorUsage
|
|
260
260
|
};
|
|
261
|
-
//# sourceMappingURL=chunk-
|
|
261
|
+
//# sourceMappingURL=chunk-V36LS5YV.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-K443GQY5.js";
|
|
4
4
|
import {
|
|
5
5
|
DEFAULT_MAPS_PROXY_MODE
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-CB5C3BPB.js";
|
|
7
7
|
|
|
8
8
|
// src/lib/slugify.ts
|
|
9
9
|
function slugify(s) {
|
|
@@ -1925,4 +1925,4 @@ export {
|
|
|
1925
1925
|
runWorkflow,
|
|
1926
1926
|
runWorkflowStep
|
|
1927
1927
|
};
|
|
1928
|
-
//# sourceMappingURL=chunk-
|
|
1928
|
+
//# sourceMappingURL=chunk-ZID3WQID.js.map
|
|
@@ -34,8 +34,10 @@ import {
|
|
|
34
34
|
failWorkflowRunRecord,
|
|
35
35
|
finishHarvestAttempt,
|
|
36
36
|
generateApiKey,
|
|
37
|
+
getBillingLedgerSummary,
|
|
37
38
|
getClient,
|
|
38
39
|
getDb,
|
|
40
|
+
getInboxMessage,
|
|
39
41
|
getJob,
|
|
40
42
|
getKpoJob,
|
|
41
43
|
getKpoPhaseLog,
|
|
@@ -56,10 +58,13 @@ import {
|
|
|
56
58
|
getWorkflowRunStepState,
|
|
57
59
|
getWorkflowSchedule,
|
|
58
60
|
hashPassword,
|
|
61
|
+
insertInboxMessage,
|
|
59
62
|
ledgerExistsForOperation,
|
|
60
63
|
ledgerExistsForStripePI,
|
|
64
|
+
listActiveUserIds,
|
|
61
65
|
listDueWorkflowSchedules,
|
|
62
66
|
listHarvestAttempts,
|
|
67
|
+
listInboxMessages,
|
|
63
68
|
listJobs,
|
|
64
69
|
listKpoJobs,
|
|
65
70
|
listRequestEvents,
|
|
@@ -69,6 +74,7 @@ import {
|
|
|
69
74
|
listWorkflowSchedules,
|
|
70
75
|
logKpoPhaseComplete,
|
|
71
76
|
logRequestEvent,
|
|
77
|
+
markInboxMessageOpened,
|
|
72
78
|
markWorkflowRunRunning,
|
|
73
79
|
markWorkflowScheduleRan,
|
|
74
80
|
migrate,
|
|
@@ -96,12 +102,13 @@ import {
|
|
|
96
102
|
setSubscriptionTier,
|
|
97
103
|
setUserMemoryCreds,
|
|
98
104
|
settleDebitMcIdempotent,
|
|
105
|
+
softDeleteInboxMessage,
|
|
99
106
|
startHarvestAttempt,
|
|
100
107
|
stripeEventAlreadyProcessed,
|
|
101
108
|
updateKpoJobState,
|
|
102
109
|
upsertPageSnapshot,
|
|
103
110
|
verifyPassword
|
|
104
|
-
} from "./chunk-
|
|
111
|
+
} from "./chunk-62DQAWPF.js";
|
|
105
112
|
export {
|
|
106
113
|
CREDIT_LOT_TTL,
|
|
107
114
|
SiteAuditJobRowSchema,
|
|
@@ -138,8 +145,10 @@ export {
|
|
|
138
145
|
failWorkflowRunRecord,
|
|
139
146
|
finishHarvestAttempt,
|
|
140
147
|
generateApiKey,
|
|
148
|
+
getBillingLedgerSummary,
|
|
141
149
|
getClient,
|
|
142
150
|
getDb,
|
|
151
|
+
getInboxMessage,
|
|
143
152
|
getJob,
|
|
144
153
|
getKpoJob,
|
|
145
154
|
getKpoPhaseLog,
|
|
@@ -160,10 +169,13 @@ export {
|
|
|
160
169
|
getWorkflowRunStepState,
|
|
161
170
|
getWorkflowSchedule,
|
|
162
171
|
hashPassword,
|
|
172
|
+
insertInboxMessage,
|
|
163
173
|
ledgerExistsForOperation,
|
|
164
174
|
ledgerExistsForStripePI,
|
|
175
|
+
listActiveUserIds,
|
|
165
176
|
listDueWorkflowSchedules,
|
|
166
177
|
listHarvestAttempts,
|
|
178
|
+
listInboxMessages,
|
|
167
179
|
listJobs,
|
|
168
180
|
listKpoJobs,
|
|
169
181
|
listRequestEvents,
|
|
@@ -173,6 +185,7 @@ export {
|
|
|
173
185
|
listWorkflowSchedules,
|
|
174
186
|
logKpoPhaseComplete,
|
|
175
187
|
logRequestEvent,
|
|
188
|
+
markInboxMessageOpened,
|
|
176
189
|
markWorkflowRunRunning,
|
|
177
190
|
markWorkflowScheduleRan,
|
|
178
191
|
migrate,
|
|
@@ -200,10 +213,11 @@ export {
|
|
|
200
213
|
setSubscriptionTier,
|
|
201
214
|
setUserMemoryCreds,
|
|
202
215
|
settleDebitMcIdempotent,
|
|
216
|
+
softDeleteInboxMessage,
|
|
203
217
|
startHarvestAttempt,
|
|
204
218
|
stripeEventAlreadyProcessed,
|
|
205
219
|
updateKpoJobState,
|
|
206
220
|
upsertPageSnapshot,
|
|
207
221
|
verifyPassword
|
|
208
222
|
};
|
|
209
|
-
//# sourceMappingURL=db-
|
|
223
|
+
//# sourceMappingURL=db-YAI5AQOI.js.map
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "./chunk-R7EETU7Z.js";
|
|
11
11
|
import {
|
|
12
12
|
getDb
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-62DQAWPF.js";
|
|
14
14
|
|
|
15
15
|
// src/api/extract-bundle.ts
|
|
16
16
|
import { createWriteStream, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "fs";
|
|
@@ -328,4 +328,4 @@ ${renderImageSection(extras.imageAudit)}`;
|
|
|
328
328
|
export {
|
|
329
329
|
assembleExtractArtifacts
|
|
330
330
|
};
|
|
331
|
-
//# sourceMappingURL=extract-bundle-
|
|
331
|
+
//# sourceMappingURL=extract-bundle-GPZRLBVY.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -64,8 +64,23 @@ var HarvestOptionsSchema = import_zod.z.object({
|
|
|
64
64
|
format: import_zod.z.enum(["json", "csv", "both"]).default("both"),
|
|
65
65
|
serpOnly: import_zod.z.boolean().default(false),
|
|
66
66
|
pages: import_zod.z.number().int().min(1).max(2).default(1),
|
|
67
|
+
recency: import_zod.z.enum(["day", "week", "month", "year"]).optional(),
|
|
67
68
|
softDeadlineMs: import_zod.z.number().optional()
|
|
68
69
|
});
|
|
70
|
+
function recencyToTbs(recency) {
|
|
71
|
+
switch (recency) {
|
|
72
|
+
case "day":
|
|
73
|
+
return "qdr:d";
|
|
74
|
+
case "week":
|
|
75
|
+
return "qdr:w";
|
|
76
|
+
case "month":
|
|
77
|
+
return "qdr:m";
|
|
78
|
+
case "year":
|
|
79
|
+
return "qdr:y";
|
|
80
|
+
default:
|
|
81
|
+
return void 0;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
69
84
|
var MapsPlaceOptionsSchema = import_zod.z.object({
|
|
70
85
|
businessName: import_zod.z.string().min(1),
|
|
71
86
|
location: import_zod.z.string().min(1),
|
|
@@ -887,6 +902,7 @@ var BrowserDriver = class {
|
|
|
887
902
|
async navigateToSERP(query, uule, gl, hl, options) {
|
|
888
903
|
const params = new URLSearchParams({ q: query, gl, hl, pws: "0" });
|
|
889
904
|
if (options?.num) params.set("num", String(options.num));
|
|
905
|
+
if (options?.tbs) params.set("tbs", options.tbs);
|
|
890
906
|
if (uule) params.set("uule", uule);
|
|
891
907
|
const url = "https://www.google.com/search?" + params.toString();
|
|
892
908
|
const navUrl = serpArrivalUrl(url);
|
|
@@ -2453,6 +2469,7 @@ var PAAExtractor = class {
|
|
|
2453
2469
|
options.hl,
|
|
2454
2470
|
{
|
|
2455
2471
|
...options.serpOnly ? { num: 100 } : {},
|
|
2472
|
+
...recencyToTbs(options.recency) ? { tbs: recencyToTbs(options.recency) } : {},
|
|
2456
2473
|
debug: options.debug
|
|
2457
2474
|
}
|
|
2458
2475
|
);
|
|
@@ -2472,6 +2489,8 @@ var PAAExtractor = class {
|
|
|
2472
2489
|
let allOrganic2 = organicResults2;
|
|
2473
2490
|
if ((options.pages ?? 1) >= 2) {
|
|
2474
2491
|
const p2params = new URLSearchParams({ q: options.query, gl: options.gl, hl: options.hl, pws: "0", start: "10" });
|
|
2492
|
+
if (recencyToTbs(options.recency)) p2params.set("tbs", recencyToTbs(options.recency));
|
|
2493
|
+
if (recencyToTbs(options.recency)) p2params.set("tbs", recencyToTbs(options.recency));
|
|
2475
2494
|
if (uule) p2params.set("uule", uule);
|
|
2476
2495
|
await this.driver.navigateTo("https://www.google.com/search?" + p2params.toString());
|
|
2477
2496
|
await this.throwIfCaptcha(page, "Google SERP page 2");
|
|
@@ -2531,6 +2550,8 @@ var PAAExtractor = class {
|
|
|
2531
2550
|
let locationEvidence2 = initialLocationEvidence;
|
|
2532
2551
|
if ((options.pages ?? 1) >= 2) {
|
|
2533
2552
|
const p2params = new URLSearchParams({ q: options.query, gl: options.gl, hl: options.hl, pws: "0", start: "10" });
|
|
2553
|
+
if (recencyToTbs(options.recency)) p2params.set("tbs", recencyToTbs(options.recency));
|
|
2554
|
+
if (recencyToTbs(options.recency)) p2params.set("tbs", recencyToTbs(options.recency));
|
|
2534
2555
|
if (uule) p2params.set("uule", uule);
|
|
2535
2556
|
await this.driver.navigateTo("https://www.google.com/search?" + p2params.toString());
|
|
2536
2557
|
await this.throwIfCaptcha(page, "Google SERP page 2");
|
|
@@ -2597,6 +2618,7 @@ var PAAExtractor = class {
|
|
|
2597
2618
|
let locationEvidence = initialLocationEvidence;
|
|
2598
2619
|
if ((options.pages ?? 1) >= 2) {
|
|
2599
2620
|
const p2params = new URLSearchParams({ q: options.query, gl: options.gl, hl: options.hl, pws: "0", start: "10" });
|
|
2621
|
+
if (recencyToTbs(options.recency)) p2params.set("tbs", recencyToTbs(options.recency));
|
|
2600
2622
|
if (uule) p2params.set("uule", uule);
|
|
2601
2623
|
await this.driver.navigateTo("https://www.google.com/search?" + p2params.toString());
|
|
2602
2624
|
await this.throwIfCaptcha(page, "Google SERP page 2");
|
|
@@ -2782,7 +2804,76 @@ var ProgressReporter = class {
|
|
|
2782
2804
|
};
|
|
2783
2805
|
|
|
2784
2806
|
// src/kernel-proxy-resolver.ts
|
|
2807
|
+
var import_sdk3 = __toESM(require("@onkernel/sdk"), 1);
|
|
2808
|
+
|
|
2809
|
+
// src/backup-proxy.ts
|
|
2810
|
+
var import_node_crypto3 = require("crypto");
|
|
2785
2811
|
var import_sdk2 = __toESM(require("@onkernel/sdk"), 1);
|
|
2812
|
+
var BACKUP_PROXY_HOST = "pr.oxylabs.io";
|
|
2813
|
+
var BACKUP_PROXY_PORT = 7777;
|
|
2814
|
+
var BACKUP_STICKY_SESSION_MINUTES = 10;
|
|
2815
|
+
var BACKUP_LAST_RESORT_ATTEMPTS = 2;
|
|
2816
|
+
function backupProxyUsername() {
|
|
2817
|
+
const value = process.env.OXYLABS_USERNAME?.trim();
|
|
2818
|
+
return value || void 0;
|
|
2819
|
+
}
|
|
2820
|
+
function backupProxyPassword() {
|
|
2821
|
+
const value = process.env.OXYLABS_PASSWORD?.trim();
|
|
2822
|
+
return value || void 0;
|
|
2823
|
+
}
|
|
2824
|
+
function backupProxyCountry() {
|
|
2825
|
+
const value = process.env.OXYLABS_COUNTRY?.trim();
|
|
2826
|
+
return (value || "US").toUpperCase();
|
|
2827
|
+
}
|
|
2828
|
+
function backupProxyAvailable() {
|
|
2829
|
+
return Boolean(backupProxyUsername() && backupProxyPassword());
|
|
2830
|
+
}
|
|
2831
|
+
function randomStickySessionId() {
|
|
2832
|
+
let digits = "";
|
|
2833
|
+
for (let i = 0; i < 10; i++) digits += String((0, import_node_crypto3.randomInt)(0, 10));
|
|
2834
|
+
return digits;
|
|
2835
|
+
}
|
|
2836
|
+
function buildBackupUsername(opts = {}) {
|
|
2837
|
+
const user = backupProxyUsername();
|
|
2838
|
+
if (!user) return void 0;
|
|
2839
|
+
const base = user.startsWith("customer-") ? user : `customer-${user}`;
|
|
2840
|
+
const country = (opts.country?.trim() || backupProxyCountry()).toUpperCase();
|
|
2841
|
+
const sticky = opts.sticky ? `-sessid-${randomStickySessionId()}-sesstime-${BACKUP_STICKY_SESSION_MINUTES}` : "";
|
|
2842
|
+
return `${base}-cc-${country}${sticky}`;
|
|
2843
|
+
}
|
|
2844
|
+
function scrubBackupProxyText(message) {
|
|
2845
|
+
return message.replace(/pr\.oxylabs\.io(:\d+)?/gi, "backup proxy").replace(/oxylabs/gi, "backup proxy");
|
|
2846
|
+
}
|
|
2847
|
+
function backupProxyName(attemptIndex) {
|
|
2848
|
+
const stamp = `${Date.now()}-${attemptIndex ?? 0}-${Math.random().toString(36).slice(2, 8)}`;
|
|
2849
|
+
return `mcp-backup-custom-${stamp}`;
|
|
2850
|
+
}
|
|
2851
|
+
async function createBackupProxyId(kernelApiKey, opts = {}) {
|
|
2852
|
+
const username = buildBackupUsername({ sticky: opts.sticky });
|
|
2853
|
+
const password = backupProxyPassword();
|
|
2854
|
+
if (!username || !password) throw new Error("backup proxy pool is not configured");
|
|
2855
|
+
const kernel = new import_sdk2.default({ apiKey: kernelApiKey });
|
|
2856
|
+
try {
|
|
2857
|
+
const created = await kernel.proxies.create({
|
|
2858
|
+
type: "custom",
|
|
2859
|
+
name: backupProxyName(opts.attemptIndex),
|
|
2860
|
+
protocol: "http",
|
|
2861
|
+
config: {
|
|
2862
|
+
host: BACKUP_PROXY_HOST,
|
|
2863
|
+
port: BACKUP_PROXY_PORT,
|
|
2864
|
+
username,
|
|
2865
|
+
password
|
|
2866
|
+
}
|
|
2867
|
+
});
|
|
2868
|
+
if (!created.id) throw new Error("backup proxy creation did not return a proxy id");
|
|
2869
|
+
return created.id;
|
|
2870
|
+
} catch (err) {
|
|
2871
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
2872
|
+
throw new Error(scrubBackupProxyText(message));
|
|
2873
|
+
}
|
|
2874
|
+
}
|
|
2875
|
+
|
|
2876
|
+
// src/kernel-proxy-resolver.ts
|
|
2786
2877
|
var US_STATE_CODES = {
|
|
2787
2878
|
alabama: "AL",
|
|
2788
2879
|
alaska: "AK",
|
|
@@ -2880,7 +2971,7 @@ function proxyIdSuffix2(proxyId) {
|
|
|
2880
2971
|
return proxyId ? proxyId.slice(-6) : null;
|
|
2881
2972
|
}
|
|
2882
2973
|
function resolution(source, proxyMode, proxyId, target, error, disposable = false) {
|
|
2883
|
-
const proxyType = source === "disabled" ? "none" : source === "configured_fallback" ? "configured" : source === "isp_created" ? "isp" : source === "location_created" || source === "location_reused" ? "residential" : "unknown";
|
|
2974
|
+
const proxyType = source === "disabled" ? "none" : source === "configured_fallback" ? "configured" : source === "isp_created" ? "isp" : source === "backup_custom" ? "custom" : source === "location_created" || source === "location_reused" ? "residential" : "unknown";
|
|
2884
2975
|
return {
|
|
2885
2976
|
kernelProxyId: proxyId,
|
|
2886
2977
|
...disposable && proxyId ? { disposableProxyId: proxyId } : {},
|
|
@@ -3064,6 +3155,26 @@ function freshTargetCandidates(target, explicitZip, attemptIndex) {
|
|
|
3064
3155
|
out.push(withProxyName(fallbackTarget, freshProxyName(fallbackTarget.proxyName, attemptIndex)));
|
|
3065
3156
|
return out;
|
|
3066
3157
|
}
|
|
3158
|
+
async function settleCreateExhaustion(options, target, createErrors) {
|
|
3159
|
+
if (options.backupOnExhaustion && createErrors.length > 0 && options.kernelApiKey && backupProxyAvailable()) {
|
|
3160
|
+
try {
|
|
3161
|
+
const backupId = await createBackupProxyId(options.kernelApiKey, { attemptIndex: options.attemptIndex });
|
|
3162
|
+
return resolution("backup_custom", options.proxyMode, backupId, target, null, true);
|
|
3163
|
+
} catch (err) {
|
|
3164
|
+
createErrors.push(`backup: ${scrubBackupProxyText(errorText2(err))}`);
|
|
3165
|
+
}
|
|
3166
|
+
}
|
|
3167
|
+
return resolution("configured_fallback", options.proxyMode, options.configuredKernelProxyId, target, createErrors.join(" | "));
|
|
3168
|
+
}
|
|
3169
|
+
async function resolveBackupKernelProxyId(options) {
|
|
3170
|
+
if (!options.kernelApiKey || !backupProxyAvailable()) return null;
|
|
3171
|
+
try {
|
|
3172
|
+
const backupId = await createBackupProxyId(options.kernelApiKey, { attemptIndex: options.attemptIndex });
|
|
3173
|
+
return resolution("backup_custom", options.proxyMode, backupId, null, null, true);
|
|
3174
|
+
} catch {
|
|
3175
|
+
return null;
|
|
3176
|
+
}
|
|
3177
|
+
}
|
|
3067
3178
|
async function createFreshLocationProxy(kernel, options, target) {
|
|
3068
3179
|
const createErrors = [];
|
|
3069
3180
|
for (const candidate of freshTargetCandidates(target, options.proxyZip, options.attemptIndex)) {
|
|
@@ -3097,11 +3208,11 @@ async function createFreshLocationProxy(kernel, options, target) {
|
|
|
3097
3208
|
createErrors.push(`isp: ${errorText2(err)}`);
|
|
3098
3209
|
}
|
|
3099
3210
|
}
|
|
3100
|
-
return
|
|
3211
|
+
return settleCreateExhaustion(options, target, createErrors);
|
|
3101
3212
|
}
|
|
3102
3213
|
async function deleteKernelProxyId(kernelApiKey, proxyId) {
|
|
3103
3214
|
if (!kernelApiKey || !proxyId) return;
|
|
3104
|
-
const kernel = new
|
|
3215
|
+
const kernel = new import_sdk3.default({ apiKey: kernelApiKey });
|
|
3105
3216
|
await kernel.proxies.delete(proxyId);
|
|
3106
3217
|
}
|
|
3107
3218
|
async function resolveKernelProxyId(options) {
|
|
@@ -3115,7 +3226,7 @@ async function resolveKernelProxyId(options) {
|
|
|
3115
3226
|
if (!target || !options.kernelApiKey) {
|
|
3116
3227
|
return resolution("configured_fallback", options.proxyMode, options.configuredKernelProxyId, target, target ? null : "location could not be normalized to a US city/state proxy target");
|
|
3117
3228
|
}
|
|
3118
|
-
const kernel = new
|
|
3229
|
+
const kernel = new import_sdk3.default({ apiKey: options.kernelApiKey });
|
|
3119
3230
|
try {
|
|
3120
3231
|
const attemptIndex = options.attemptIndex ?? 0;
|
|
3121
3232
|
if (options.fresh) {
|
|
@@ -3137,7 +3248,7 @@ async function resolveKernelProxyId(options) {
|
|
|
3137
3248
|
} catch (err) {
|
|
3138
3249
|
createErrors2.push(`${escalatedTarget.state}: ${errorText2(err)}`);
|
|
3139
3250
|
}
|
|
3140
|
-
return
|
|
3251
|
+
return settleCreateExhaustion(options, escalatedTarget, createErrors2);
|
|
3141
3252
|
}
|
|
3142
3253
|
const proxies = await kernel.proxies.list();
|
|
3143
3254
|
const zip = knownZipFor(target, options.proxyZip);
|
|
@@ -3216,7 +3327,7 @@ async function resolveKernelProxyId(options) {
|
|
|
3216
3327
|
} catch (err) {
|
|
3217
3328
|
createErrors.push(`${fallbackTarget.state}: ${errorText2(err)}`);
|
|
3218
3329
|
}
|
|
3219
|
-
return
|
|
3330
|
+
return settleCreateExhaustion(options, target, createErrors);
|
|
3220
3331
|
} catch (err) {
|
|
3221
3332
|
return resolution("configured_fallback", options.proxyMode, options.configuredKernelProxyId, target, errorText2(err));
|
|
3222
3333
|
}
|
|
@@ -3381,7 +3492,9 @@ async function harvest(rawOptions) {
|
|
|
3381
3492
|
const requestedDebug = typeof raw.debug === "boolean" ? raw.debug : false;
|
|
3382
3493
|
const needsLocationEvidence = proxyMode === "location" && Boolean(proxyOpts.location);
|
|
3383
3494
|
const requestedMaxAttempts = raw.maxAttempts;
|
|
3384
|
-
const
|
|
3495
|
+
const baseMaxAttempts = typeof requestedMaxAttempts === "number" && Number.isInteger(requestedMaxAttempts) && requestedMaxAttempts >= 1 ? requestedMaxAttempts : maxAttemptsForProxyMode(proxyMode) + 1;
|
|
3496
|
+
const maxAttempts = baseMaxAttempts + (backupProxyAvailable() ? BACKUP_LAST_RESORT_ATTEMPTS : 0);
|
|
3497
|
+
const softDeadlineMs = typeof raw.softDeadlineMs === "number" ? raw.softDeadlineMs : null;
|
|
3385
3498
|
const serializer = new OutputSerializer();
|
|
3386
3499
|
let lastError = null;
|
|
3387
3500
|
let effectiveProxyMode = proxyMode;
|
|
@@ -3391,12 +3504,16 @@ async function harvest(rawOptions) {
|
|
|
3391
3504
|
const startedAtMs = Date.now();
|
|
3392
3505
|
try {
|
|
3393
3506
|
if (signal?.aborted) throw abortReason(signal);
|
|
3394
|
-
const
|
|
3507
|
+
const isBackupAttempt = i >= baseMaxAttempts;
|
|
3508
|
+
if (isBackupAttempt && softDeadlineMs !== null && Date.now() >= softDeadlineMs) break;
|
|
3509
|
+
const resolution2 = isBackupAttempt ? await resolveBackupKernelProxyId({ kernelApiKey, proxyMode: effectiveProxyMode, attemptIndex: i }) : await resolveKernelProxyId({
|
|
3395
3510
|
...proxyOpts,
|
|
3396
3511
|
proxyMode: effectiveProxyMode,
|
|
3397
3512
|
attemptIndex: i,
|
|
3398
|
-
fresh: effectiveProxyMode === "location"
|
|
3513
|
+
fresh: effectiveProxyMode === "location",
|
|
3514
|
+
backupOnExhaustion: true
|
|
3399
3515
|
});
|
|
3516
|
+
if (!resolution2) break;
|
|
3400
3517
|
const mergedAttempt = {
|
|
3401
3518
|
...raw,
|
|
3402
3519
|
kernelApiKey,
|
|
@@ -3405,7 +3522,7 @@ async function harvest(rawOptions) {
|
|
|
3405
3522
|
proxyMode: effectiveProxyMode,
|
|
3406
3523
|
debug: requestedDebug || needsLocationEvidence
|
|
3407
3524
|
};
|
|
3408
|
-
if (effectiveProxyMode === "none") mergedAttempt.kernelProxyId = void 0;
|
|
3525
|
+
if (effectiveProxyMode === "none" && !isBackupAttempt) mergedAttempt.kernelProxyId = void 0;
|
|
3409
3526
|
const attemptOptions = HarvestOptionsSchema.parse(mergedAttempt);
|
|
3410
3527
|
await emitAttemptEvent(onAttemptEvent, {
|
|
3411
3528
|
type: "started",
|
|
@@ -3424,10 +3541,8 @@ async function harvest(rawOptions) {
|
|
|
3424
3541
|
location: attemptOptions.location ?? null,
|
|
3425
3542
|
max_questions: attemptOptions.maxQuestions
|
|
3426
3543
|
}));
|
|
3427
|
-
const isHeadfulEscalation = i === maxAttempts - 1;
|
|
3428
|
-
const needHeadful = isHeadfulEscalation || !attemptOptions.serpOnly;
|
|
3429
3544
|
const baseCtx = currentCostContext();
|
|
3430
|
-
const attempt =
|
|
3545
|
+
const attempt = baseCtx ? await runWithCostContext({ ...baseCtx, forceHeadful: true }, () => extractOnce(attemptOptions, signal)) : await extractOnce(attemptOptions, signal);
|
|
3431
3546
|
if (attempt.error) {
|
|
3432
3547
|
const err = attempt.error;
|
|
3433
3548
|
const outcome = classifyAttemptError(err);
|