mcp-scraper 0.88.2 → 0.89.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/CHANGELOG.md +36 -15
- package/README.md +6 -5
- package/THIRD_PARTY_NOTICES.html +203 -0
- package/dist/analytics-repository-2BMT5JNE.js +1 -0
- package/dist/bin/api-server.js +2 -41
- package/dist/bin/mcp-scraper-cli.js +39 -756
- package/dist/bin/mcp-scraper-core.js +1 -60
- package/dist/bin/mcp-scraper-install.js +2 -25
- package/dist/bin/mcp-stdio-server.js +1 -19
- package/dist/bin/paa-harvest.js +1 -41
- package/dist/chunk-3GP5CYZX.js +1 -0
- package/dist/chunk-4AI7DOS7.js +59 -0
- package/dist/chunk-4FROKQJN.js +1 -0
- package/dist/chunk-7YGVI5J4.js +21710 -0
- package/dist/chunk-CCYWSJNG.js +16 -0
- package/dist/chunk-CFI6CXIV.js +182 -0
- package/dist/chunk-E2WRWV3A.js +1 -0
- package/dist/chunk-GMWKPIYX.js +1172 -0
- package/dist/chunk-HDPYG3XV.js +102 -0
- package/dist/chunk-HE45FFBU.js +1 -0
- package/dist/chunk-HUV2WTRW.js +1 -0
- package/dist/chunk-KJQXUZ4Y.js +4 -0
- package/dist/chunk-L4CGLFPU.js +4 -0
- package/dist/chunk-M22MM4N4.js +84 -0
- package/dist/chunk-MASR22K4.js +73 -0
- package/dist/chunk-MZN4U5BL.js +1 -0
- package/dist/chunk-PUHFVA7P.js +1280 -0
- package/dist/chunk-QPWPR5XG.js +10 -0
- package/dist/chunk-TMB56NCA.js +1 -0
- package/dist/chunk-TXENITMS.js +20 -0
- package/dist/chunk-W2BVJ7S2.js +13 -0
- package/dist/chunk-WO3N5FH2.js +5 -0
- package/dist/chunk-WSCGYRWA.js +2595 -0
- package/dist/chunk-X54CQLK2.js +1 -0
- package/dist/chunk-XLWNEVUZ.js +27 -0
- package/dist/chunk-XPZVJIZ2.js +100 -0
- package/dist/chunk-YQZGZBB4.js +1 -0
- package/dist/chunk-Z2QGQJS2.js +1 -0
- package/dist/db-F2MX63GI.js +1 -0
- package/dist/extract-bundle-SNUIHM3J.js +26 -0
- package/dist/gmail-service-BZ3H75XC.js +1 -0
- package/dist/index.cjs +21750 -6045
- package/dist/index.d.cts +14 -14
- package/dist/index.d.ts +14 -14
- package/dist/index.js +18 -315
- package/dist/lead-list-enrichment-repository-S2H3U7T7.js +1 -0
- package/dist/location-data-repository-OTWHWMV6.js +1 -0
- package/dist/server-RFR2A5UJ.js +7303 -0
- package/dist/site-extract-repository-SE776XDC.js +1 -0
- package/dist/worker-XUDSM3AL.js +1 -0
- package/package.json +17 -124
- package/dist/analytics-repository-GGJJCVVP.js +0 -194
- package/dist/chunk-4QMUF6XM.js +0 -1013
- package/dist/chunk-6HAV7LCE.js +0 -265
- package/dist/chunk-ABF2CGOZ.js +0 -113
- package/dist/chunk-C5Z4OFKW.js +0 -404
- package/dist/chunk-DNM65UCK.js +0 -299
- package/dist/chunk-EQGTEHLZ.js +0 -592
- package/dist/chunk-F5GQJWZU.js +0 -732
- package/dist/chunk-GGZEC22A.js +0 -215
- package/dist/chunk-GXBZXWXB.js +0 -184
- package/dist/chunk-IHXAXYIS.js +0 -843
- package/dist/chunk-K3Z5AQYE.js +0 -683
- package/dist/chunk-K45K75OF.js +0 -6
- package/dist/chunk-LFW2FRPJ.js +0 -224
- package/dist/chunk-MZDNZQWT.js +0 -2078
- package/dist/chunk-NVUKO5NN.js +0 -256
- package/dist/chunk-OM7HVEJ3.js +0 -26
- package/dist/chunk-OPQIGAFB.js +0 -286
- package/dist/chunk-OZJMVCDK.js +0 -16
- package/dist/chunk-P7FWOMU7.js +0 -505
- package/dist/chunk-PGJQDMC2.js +0 -383
- package/dist/chunk-PKZS6SHW.js +0 -33139
- package/dist/chunk-RJ7JVYKU.js +0 -68
- package/dist/chunk-S24LFPL7.js +0 -5262
- package/dist/chunk-T3MZISOF.js +0 -240
- package/dist/chunk-UZPTGUDV.js +0 -1915
- package/dist/chunk-X623GTBV.js +0 -8290
- package/dist/chunk-YXNDOQXN.js +0 -4018
- package/dist/db-Z34LPZNR.js +0 -284
- package/dist/extract-bundle-565SBZCR.js +0 -1003
- package/dist/gmail-service-E6ALS7JG.js +0 -25
- package/dist/lead-list-enrichment-repository-36RPVV6N.js +0 -67
- package/dist/location-data-repository-WPRG62GE.js +0 -34
- package/dist/server-SQZ3A7SY.js +0 -86606
- package/dist/site-extract-repository-VYFZASPU.js +0 -69
- package/dist/worker-LDCAULWL.js +0 -146
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
XRAY_ENTITLED_EXTRACT_BILLING_CLASS,
|
|
3
|
-
abandonExtractSettlement,
|
|
4
|
-
claimFailedExtractJobForRefinalize,
|
|
5
|
-
completeExtractJob,
|
|
6
|
-
countSuccessfulPages,
|
|
7
|
-
createExtractJob,
|
|
8
|
-
createOrGetExtractJob,
|
|
9
|
-
extractJobLimitInfo,
|
|
10
|
-
failExtractJob,
|
|
11
|
-
failStaleRunningExtractJob,
|
|
12
|
-
failUnfundedExtractJob,
|
|
13
|
-
finalizeXRayEntitledExtractJobCharge,
|
|
14
|
-
finishExtractJob,
|
|
15
|
-
getExtractJob,
|
|
16
|
-
getExtractJobByIdempotencyKey,
|
|
17
|
-
getExtractedImageLinks,
|
|
18
|
-
getExtractedPages,
|
|
19
|
-
getExtractedUrls,
|
|
20
|
-
listExtractJobs,
|
|
21
|
-
listExtractPages,
|
|
22
|
-
listFundedPendingExtractJobs,
|
|
23
|
-
listStaleRunningExtractJobs,
|
|
24
|
-
listUnsettledExtractJobs,
|
|
25
|
-
markExtractJobDispatchAttempt,
|
|
26
|
-
recordExtractJobDispatchFailure,
|
|
27
|
-
recordExtractSettlementFailure,
|
|
28
|
-
saveExtractPages,
|
|
29
|
-
setExtractJobPublicError,
|
|
30
|
-
setExtractJobTotal,
|
|
31
|
-
settleExtractJob,
|
|
32
|
-
terminalExtractJobStatus
|
|
33
|
-
} from "./chunk-IHXAXYIS.js";
|
|
34
|
-
import "./chunk-DNM65UCK.js";
|
|
35
|
-
import "./chunk-4QMUF6XM.js";
|
|
36
|
-
import "./chunk-YXNDOQXN.js";
|
|
37
|
-
export {
|
|
38
|
-
XRAY_ENTITLED_EXTRACT_BILLING_CLASS,
|
|
39
|
-
abandonExtractSettlement,
|
|
40
|
-
claimFailedExtractJobForRefinalize,
|
|
41
|
-
completeExtractJob,
|
|
42
|
-
countSuccessfulPages,
|
|
43
|
-
createExtractJob,
|
|
44
|
-
createOrGetExtractJob,
|
|
45
|
-
extractJobLimitInfo,
|
|
46
|
-
failExtractJob,
|
|
47
|
-
failStaleRunningExtractJob,
|
|
48
|
-
failUnfundedExtractJob,
|
|
49
|
-
finalizeXRayEntitledExtractJobCharge,
|
|
50
|
-
finishExtractJob,
|
|
51
|
-
getExtractJob,
|
|
52
|
-
getExtractJobByIdempotencyKey,
|
|
53
|
-
getExtractedImageLinks,
|
|
54
|
-
getExtractedPages,
|
|
55
|
-
getExtractedUrls,
|
|
56
|
-
listExtractJobs,
|
|
57
|
-
listExtractPages,
|
|
58
|
-
listFundedPendingExtractJobs,
|
|
59
|
-
listStaleRunningExtractJobs,
|
|
60
|
-
listUnsettledExtractJobs,
|
|
61
|
-
markExtractJobDispatchAttempt,
|
|
62
|
-
recordExtractJobDispatchFailure,
|
|
63
|
-
recordExtractSettlementFailure,
|
|
64
|
-
saveExtractPages,
|
|
65
|
-
setExtractJobPublicError,
|
|
66
|
-
setExtractJobTotal,
|
|
67
|
-
settleExtractJob,
|
|
68
|
-
terminalExtractJobStatus
|
|
69
|
-
};
|
package/dist/worker-LDCAULWL.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
classifyHarvestProblem,
|
|
3
|
-
createHarvestAttemptRecorder,
|
|
4
|
-
deliverWebhook,
|
|
5
|
-
harvestProblemEnvelope,
|
|
6
|
-
harvestProblemResponse,
|
|
7
|
-
serializeHarvestProblem
|
|
8
|
-
} from "./chunk-NVUKO5NN.js";
|
|
9
|
-
import "./chunk-OZJMVCDK.js";
|
|
10
|
-
import {
|
|
11
|
-
harvest
|
|
12
|
-
} from "./chunk-S24LFPL7.js";
|
|
13
|
-
import {
|
|
14
|
-
sanitizeAttempts,
|
|
15
|
-
sanitizeHarvestResult
|
|
16
|
-
} from "./chunk-6HAV7LCE.js";
|
|
17
|
-
import {
|
|
18
|
-
MC_COSTS,
|
|
19
|
-
serpActualCostMc
|
|
20
|
-
} from "./chunk-4QMUF6XM.js";
|
|
21
|
-
import {
|
|
22
|
-
browserServiceApiKey
|
|
23
|
-
} from "./chunk-OM7HVEJ3.js";
|
|
24
|
-
import {
|
|
25
|
-
runWithCostContext
|
|
26
|
-
} from "./chunk-OPQIGAFB.js";
|
|
27
|
-
import "./chunk-GXBZXWXB.js";
|
|
28
|
-
import {
|
|
29
|
-
claimPendingJob,
|
|
30
|
-
completeJob,
|
|
31
|
-
creditMc,
|
|
32
|
-
debitMc,
|
|
33
|
-
failJob,
|
|
34
|
-
listHarvestAttempts
|
|
35
|
-
} from "./chunk-YXNDOQXN.js";
|
|
36
|
-
|
|
37
|
-
// src/api/worker.ts
|
|
38
|
-
var MAX_CONCURRENT = 2;
|
|
39
|
-
var running = 0;
|
|
40
|
-
function countPaaQuestions(result) {
|
|
41
|
-
if (!result || typeof result !== "object") return 0;
|
|
42
|
-
const value = result;
|
|
43
|
-
if (typeof value.totalQuestions === "number") return value.totalQuestions;
|
|
44
|
-
return Array.isArray(value.flat) ? value.flat.length : 0;
|
|
45
|
-
}
|
|
46
|
-
function paaCostForQuestionCount(questionCount) {
|
|
47
|
-
return MC_COSTS.paa_base + Math.max(1, questionCount) * MC_COSTS.paa;
|
|
48
|
-
}
|
|
49
|
-
async function processJob(job) {
|
|
50
|
-
running++;
|
|
51
|
-
try {
|
|
52
|
-
const opts = typeof job.options === "string" ? JSON.parse(job.options) : job.options;
|
|
53
|
-
const headlessSentOut = { value: null };
|
|
54
|
-
const result = await runWithCostContext(
|
|
55
|
-
{ op: opts.serpOnly ? "serp" : "paa", userId: Number(job.user_id), headlessSentOut },
|
|
56
|
-
() => harvest({
|
|
57
|
-
...opts,
|
|
58
|
-
kernelApiKey: browserServiceApiKey(),
|
|
59
|
-
headless: true,
|
|
60
|
-
format: "json",
|
|
61
|
-
outputDir: "/tmp/paa-output-api",
|
|
62
|
-
onAttemptEvent: createHarvestAttemptRecorder(job.id, job.user_id)
|
|
63
|
-
})
|
|
64
|
-
);
|
|
65
|
-
await completeJob(job.id, result);
|
|
66
|
-
const attempts = await listHarvestAttempts(job.id, job.user_id);
|
|
67
|
-
if (!opts.serpOnly && typeof opts.billingHoldMc === "number") {
|
|
68
|
-
const actualCost = paaCostForQuestionCount(countPaaQuestions(result));
|
|
69
|
-
const diff = opts.billingHoldMc - actualCost;
|
|
70
|
-
if (diff > 0) await creditMc(job.user_id, diff, "paa_refund", "overestimate refund");
|
|
71
|
-
else if (diff < 0) await debitMc(job.user_id, -diff, "paa", opts.query ?? job.query);
|
|
72
|
-
} else if (opts.serpOnly && typeof opts.billingHoldMc === "number") {
|
|
73
|
-
const actualCost = serpActualCostMc(headlessSentOut.value);
|
|
74
|
-
const diff = opts.billingHoldMc - actualCost;
|
|
75
|
-
if (diff > 0) await creditMc(job.user_id, diff, "serp_refund", "headless-mode pricing settle");
|
|
76
|
-
else if (diff < 0) await debitMc(job.user_id, -diff, "serp", opts.query ?? job.query);
|
|
77
|
-
}
|
|
78
|
-
if (job.callback_url) {
|
|
79
|
-
await deliverWebhook(job.callback_url, {
|
|
80
|
-
job_id: job.id,
|
|
81
|
-
status: "done",
|
|
82
|
-
result: sanitizeHarvestResult(result),
|
|
83
|
-
attempts: sanitizeAttempts(attempts)
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
} catch (err) {
|
|
87
|
-
console.error("[harvest/worker] failed", {
|
|
88
|
-
jobId: job.id,
|
|
89
|
-
error: err instanceof Error ? err.message : String(err)
|
|
90
|
-
});
|
|
91
|
-
const problem = classifyHarvestProblem(err);
|
|
92
|
-
const failedOptions = typeof job.options === "string" ? JSON.parse(job.options) : job.options;
|
|
93
|
-
const hasHold = typeof failedOptions.billingHoldMc === "number" && failedOptions.billingHoldMc > 0;
|
|
94
|
-
await failJob(job.id, serializeHarvestProblem(problem), harvestProblemEnvelope(problem, {
|
|
95
|
-
chargeStatus: hasHold ? "refund_pending" : "not_charged"
|
|
96
|
-
}));
|
|
97
|
-
const attempts = await listHarvestAttempts(job.id, job.user_id);
|
|
98
|
-
try {
|
|
99
|
-
if (hasHold) {
|
|
100
|
-
await creditMc(job.user_id, failedOptions.billingHoldMc, "refund", "failed call");
|
|
101
|
-
await failJob(job.id, serializeHarvestProblem(problem), harvestProblemEnvelope(problem, { chargeStatus: "refunded" }));
|
|
102
|
-
}
|
|
103
|
-
} catch {
|
|
104
|
-
}
|
|
105
|
-
if (job.callback_url) {
|
|
106
|
-
await deliverWebhook(job.callback_url, {
|
|
107
|
-
job_id: job.id,
|
|
108
|
-
status: "failed",
|
|
109
|
-
...harvestProblemResponse(problem),
|
|
110
|
-
attempts: sanitizeAttempts(attempts)
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
} finally {
|
|
114
|
-
running--;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
async function tickOnce() {
|
|
118
|
-
const job = await claimPendingJob();
|
|
119
|
-
if (!job) return { claimed: false };
|
|
120
|
-
const startedAt = Date.now();
|
|
121
|
-
await processJob(job);
|
|
122
|
-
return { claimed: true, jobId: job.id, completed: true, durationMs: Date.now() - startedAt };
|
|
123
|
-
}
|
|
124
|
-
async function drainQueue(budget) {
|
|
125
|
-
const results = [];
|
|
126
|
-
for (let i = 0; i < budget.maxJobs; i++) {
|
|
127
|
-
if (Date.now() >= budget.deadlineMs) break;
|
|
128
|
-
const r = await tickOnce();
|
|
129
|
-
results.push(r);
|
|
130
|
-
if (!r.claimed) break;
|
|
131
|
-
}
|
|
132
|
-
return results;
|
|
133
|
-
}
|
|
134
|
-
function startWorker() {
|
|
135
|
-
setInterval(async () => {
|
|
136
|
-
if (running >= MAX_CONCURRENT) return;
|
|
137
|
-
const job = await claimPendingJob();
|
|
138
|
-
if (job) void processJob(job);
|
|
139
|
-
}, 2e3);
|
|
140
|
-
console.log(`[worker] started \u2014 polling every 2s, max ${MAX_CONCURRENT} concurrent`);
|
|
141
|
-
}
|
|
142
|
-
export {
|
|
143
|
-
drainQueue,
|
|
144
|
-
startWorker,
|
|
145
|
-
tickOnce
|
|
146
|
-
};
|