mcp-scraper 0.88.2 → 0.89.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/CHANGELOG.md +41 -2
  2. package/README.md +6 -3
  3. package/dist/analytics-repository-J25XR5E7.js +1 -0
  4. package/dist/bin/api-server.js +2 -41
  5. package/dist/bin/mcp-scraper-cli.js +39 -756
  6. package/dist/bin/mcp-scraper-core.js +1 -60
  7. package/dist/bin/mcp-scraper-install.js +2 -25
  8. package/dist/bin/mcp-stdio-server.js +1 -19
  9. package/dist/bin/paa-harvest.js +1 -41
  10. package/dist/chunk-3GP5CYZX.js +1 -0
  11. package/dist/chunk-4FROKQJN.js +1 -0
  12. package/dist/chunk-57AHYL2O.js +20 -0
  13. package/dist/chunk-5H3MCTTP.js +1 -0
  14. package/dist/chunk-63T4W2LX.js +1271 -0
  15. package/dist/chunk-645LQBE7.js +2595 -0
  16. package/dist/chunk-6QO4F2KC.js +21710 -0
  17. package/dist/chunk-CCYWSJNG.js +16 -0
  18. package/dist/chunk-D6IQJP64.js +84 -0
  19. package/dist/chunk-DGBLGFNJ.js +182 -0
  20. package/dist/chunk-FFPD2DOF.js +59 -0
  21. package/dist/chunk-FXEWHK54.js +1 -0
  22. package/dist/chunk-HE45FFBU.js +1 -0
  23. package/dist/chunk-HUV2WTRW.js +1 -0
  24. package/dist/chunk-IJ2AO7AO.js +102 -0
  25. package/dist/chunk-KJQXUZ4Y.js +4 -0
  26. package/dist/chunk-MEM4D2QN.js +1280 -0
  27. package/dist/chunk-MZN4U5BL.js +1 -0
  28. package/dist/chunk-PRWZNHQB.js +1 -0
  29. package/dist/chunk-QPWPR5XG.js +10 -0
  30. package/dist/chunk-RYNHNEF3.js +73 -0
  31. package/dist/chunk-TMB56NCA.js +1 -0
  32. package/dist/chunk-W2BVJ7S2.js +13 -0
  33. package/dist/chunk-WO3N5FH2.js +5 -0
  34. package/dist/chunk-XLWNEVUZ.js +27 -0
  35. package/dist/chunk-YQZGZBB4.js +1 -0
  36. package/dist/chunk-YUPLOOTB.js +4 -0
  37. package/dist/chunk-ZHORX44A.js +100 -0
  38. package/dist/db-JJWJLAVQ.js +1 -0
  39. package/dist/extract-bundle-TTSEGWYF.js +26 -0
  40. package/dist/gmail-service-34PIJRLK.js +1 -0
  41. package/dist/index.cjs +21838 -6034
  42. package/dist/index.js +18 -315
  43. package/dist/lead-list-enrichment-repository-VJBBMBCG.js +1 -0
  44. package/dist/location-data-repository-W3LPT6G3.js +1 -0
  45. package/dist/server-UEY5YQL6.js +7329 -0
  46. package/dist/site-extract-repository-7W5ZUNPR.js +1 -0
  47. package/dist/worker-ZOTOKG56.js +1 -0
  48. package/package.json +11 -4
  49. package/dist/analytics-repository-GGJJCVVP.js +0 -194
  50. package/dist/chunk-4QMUF6XM.js +0 -1013
  51. package/dist/chunk-6HAV7LCE.js +0 -265
  52. package/dist/chunk-ABF2CGOZ.js +0 -113
  53. package/dist/chunk-C5Z4OFKW.js +0 -404
  54. package/dist/chunk-DNM65UCK.js +0 -299
  55. package/dist/chunk-EQGTEHLZ.js +0 -592
  56. package/dist/chunk-F5GQJWZU.js +0 -732
  57. package/dist/chunk-GGZEC22A.js +0 -215
  58. package/dist/chunk-GXBZXWXB.js +0 -184
  59. package/dist/chunk-IHXAXYIS.js +0 -843
  60. package/dist/chunk-K3Z5AQYE.js +0 -683
  61. package/dist/chunk-K45K75OF.js +0 -6
  62. package/dist/chunk-LFW2FRPJ.js +0 -224
  63. package/dist/chunk-MZDNZQWT.js +0 -2078
  64. package/dist/chunk-NVUKO5NN.js +0 -256
  65. package/dist/chunk-OM7HVEJ3.js +0 -26
  66. package/dist/chunk-OPQIGAFB.js +0 -286
  67. package/dist/chunk-OZJMVCDK.js +0 -16
  68. package/dist/chunk-P7FWOMU7.js +0 -505
  69. package/dist/chunk-PGJQDMC2.js +0 -383
  70. package/dist/chunk-PKZS6SHW.js +0 -33139
  71. package/dist/chunk-RJ7JVYKU.js +0 -68
  72. package/dist/chunk-S24LFPL7.js +0 -5262
  73. package/dist/chunk-T3MZISOF.js +0 -240
  74. package/dist/chunk-UZPTGUDV.js +0 -1915
  75. package/dist/chunk-X623GTBV.js +0 -8290
  76. package/dist/chunk-YXNDOQXN.js +0 -4018
  77. package/dist/db-Z34LPZNR.js +0 -284
  78. package/dist/extract-bundle-565SBZCR.js +0 -1003
  79. package/dist/gmail-service-E6ALS7JG.js +0 -25
  80. package/dist/lead-list-enrichment-repository-36RPVV6N.js +0 -67
  81. package/dist/location-data-repository-WPRG62GE.js +0 -34
  82. package/dist/server-SQZ3A7SY.js +0 -86606
  83. package/dist/site-extract-repository-VYFZASPU.js +0 -69
  84. package/dist/worker-LDCAULWL.js +0 -146
@@ -1,240 +0,0 @@
1
- // src/api/connected-data-artifacts.ts
2
- import { createHash, randomUUID } from "crypto";
3
- import { mkdir, readFile, stat, writeFile } from "fs/promises";
4
- import { homedir } from "os";
5
- import { dirname, join } from "path";
6
- var CONNECTED_DATA_ARTIFACT_PREFIX = "connected-data-exports/";
7
- var CONNECTED_DATA_ARTIFACT_TTL_MS = 7 * 24 * 60 * 60 * 1e3;
8
- var CONNECTED_DATA_DOWNLOAD_TTL_MS = 15 * 60 * 1e3;
9
- function privateBlobToken() {
10
- return process.env.CONNECTED_DATA_READ_WRITE_TOKEN?.trim() || process.env.CONNECTED_DATA_BLOB_READ_WRITE_TOKEN?.trim() || null;
11
- }
12
- function localBaseDir() {
13
- return process.env.MCP_SCRAPER_OUTPUT_DIR?.trim() || join(homedir(), "Downloads", "mcp-scraper");
14
- }
15
- function isHosted() {
16
- return process.env.VERCEL === "1" || process.env.NODE_ENV === "production";
17
- }
18
- function safeFilename(value) {
19
- const safe = value.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
20
- return (safe || "connected-data-export").slice(0, 120);
21
- }
22
- function artifactTimestamp(artifactId) {
23
- if (!artifactId.startsWith(CONNECTED_DATA_ARTIFACT_PREFIX)) return null;
24
- const filename = artifactId.split("/").at(-1) ?? "";
25
- const match = filename.match(/^(\d{13})-/);
26
- if (!match) return null;
27
- const timestamp = Number(match[1]);
28
- return Number.isFinite(timestamp) ? timestamp : null;
29
- }
30
- function connectedDataArtifactOwnerId(artifactId) {
31
- if (!artifactId.startsWith(CONNECTED_DATA_ARTIFACT_PREFIX)) return null;
32
- const rest = artifactId.slice(CONNECTED_DATA_ARTIFACT_PREFIX.length);
33
- const owner = rest.split("/")[0];
34
- return owner || null;
35
- }
36
- function connectedDataArtifactExpiresAt(artifactId) {
37
- const timestamp = artifactTimestamp(artifactId);
38
- return timestamp === null ? null : new Date(timestamp + CONNECTED_DATA_ARTIFACT_TTL_MS);
39
- }
40
- function connectedDataArtifactIsExpired(artifactId, now = Date.now()) {
41
- const timestamp = artifactTimestamp(artifactId);
42
- return timestamp === null || timestamp + CONNECTED_DATA_ARTIFACT_TTL_MS <= now;
43
- }
44
- async function signedDownloadUrl(pathname, expiresAt) {
45
- const token = privateBlobToken();
46
- if (!token) return null;
47
- const validUntil = Math.min(Date.now() + CONNECTED_DATA_DOWNLOAD_TTL_MS, expiresAt.getTime());
48
- if (validUntil <= Date.now()) return null;
49
- const { issueSignedToken, presignUrl } = await import("@vercel/blob");
50
- const signedToken = await issueSignedToken({
51
- token,
52
- pathname,
53
- operations: ["get"],
54
- validUntil
55
- });
56
- const { presignedUrl } = await presignUrl(signedToken, {
57
- access: "private",
58
- operation: "get",
59
- pathname,
60
- validUntil
61
- });
62
- return { url: presignedUrl, expiresAt: new Date(validUntil).toISOString() };
63
- }
64
- async function createConnectedDataArtifact(args) {
65
- return createConnectedDataBinaryArtifact({
66
- ...args,
67
- contentType: "application/x-ndjson"
68
- });
69
- }
70
- async function createConnectedDataBinaryArtifact(args) {
71
- const requestedCreatedAt = args.stableCreatedAt ? Date.parse(args.stableCreatedAt) : Number.NaN;
72
- const createdAt = Number.isFinite(requestedCreatedAt) ? requestedCreatedAt : Date.now();
73
- const filename = safeFilename(args.filename);
74
- const extension = filename.includes(".") ? `.${filename.split(".").at(-1)}` : ".bin";
75
- const stableSuffix = args.stableKey ? safeFilename(args.stableKey) : randomUUID();
76
- const requestedPathname = `${CONNECTED_DATA_ARTIFACT_PREFIX}${args.ownerId}/${createdAt}-${safeFilename(args.exportId)}-${stableSuffix}--${filename}`;
77
- const content = typeof args.content === "string" ? Buffer.from(args.content) : Buffer.from(args.content);
78
- const bytes = content.byteLength;
79
- const sha256 = createHash("sha256").update(content).digest("hex");
80
- const expiresAt = new Date(createdAt + CONNECTED_DATA_ARTIFACT_TTL_MS);
81
- const token = privateBlobToken();
82
- let artifactId = requestedPathname;
83
- if (token) {
84
- const { put } = await import("@vercel/blob");
85
- const stored = await put(requestedPathname, content, {
86
- access: "private",
87
- token,
88
- contentType: args.contentType,
89
- addRandomSuffix: !args.stableKey,
90
- ...args.stableKey ? { allowOverwrite: true } : {},
91
- cacheControlMaxAge: 60,
92
- multipart: bytes > 100 * 1024 * 1024
93
- });
94
- artifactId = stored.pathname;
95
- } else {
96
- if (isHosted()) throw new Error("connected_data_private_blob_not_configured");
97
- const path = join(localBaseDir(), "blobs", requestedPathname);
98
- await mkdir(dirname(path), { recursive: true });
99
- await writeFile(path, content);
100
- }
101
- const download = await signedDownloadUrl(artifactId, expiresAt);
102
- return {
103
- artifactId,
104
- filename,
105
- contentType: args.contentType,
106
- bytes,
107
- sha256,
108
- createdAt: new Date(createdAt).toISOString(),
109
- expiresAt: expiresAt.toISOString(),
110
- downloadUrl: download?.url ?? null,
111
- downloadUrlExpiresAt: download?.expiresAt ?? null,
112
- readback: {
113
- tool: "report_artifact_read",
114
- arguments: { artifactId, offset: 0, maxBytes: 2e4 },
115
- continuation: "Repeat with offset set to the previous result nextOffset until nextOffset is null."
116
- }
117
- };
118
- }
119
- async function renewConnectedDataArtifactDownload(args) {
120
- if (connectedDataArtifactOwnerId(args.artifactId) !== args.ownerId) return null;
121
- const expiresAt = connectedDataArtifactExpiresAt(args.artifactId);
122
- if (!expiresAt || expiresAt.getTime() <= Date.now()) return null;
123
- const download = await signedDownloadUrl(args.artifactId, expiresAt);
124
- if (!download) return null;
125
- return {
126
- downloadUrl: download.url,
127
- downloadUrlExpiresAt: download.expiresAt,
128
- expiresAt: expiresAt.toISOString()
129
- };
130
- }
131
- async function streamToBuffer(stream, maxBytes = Number.POSITIVE_INFINITY) {
132
- const reader = stream.getReader();
133
- const chunks = [];
134
- let totalBytes = 0;
135
- try {
136
- for (; ; ) {
137
- const { done, value } = await reader.read();
138
- if (done) break;
139
- if (value) {
140
- const chunk = Buffer.from(value);
141
- totalBytes += chunk.byteLength;
142
- if (totalBytes > maxBytes) {
143
- await reader.cancel("artifact_too_large").catch(() => void 0);
144
- return null;
145
- }
146
- chunks.push(chunk);
147
- }
148
- }
149
- } finally {
150
- reader.releaseLock();
151
- }
152
- return Buffer.concat(chunks);
153
- }
154
- async function readConnectedDataArtifactWindow(artifactId, offset, maxBytes) {
155
- if (connectedDataArtifactIsExpired(artifactId)) return null;
156
- const token = privateBlobToken();
157
- let buffer;
158
- if (token) {
159
- const { get } = await import("@vercel/blob");
160
- const result = await get(artifactId, { access: "private", token, useCache: false });
161
- if (!result || result.statusCode !== 200) return null;
162
- const streamed = await streamToBuffer(result.stream);
163
- if (!streamed) return null;
164
- buffer = streamed;
165
- } else {
166
- if (isHosted()) return null;
167
- try {
168
- buffer = await readFile(join(localBaseDir(), "blobs", artifactId));
169
- } catch {
170
- return null;
171
- }
172
- }
173
- const totalBytes = buffer.length;
174
- const start = Math.max(0, offset);
175
- const end = Math.min(totalBytes, start + maxBytes);
176
- return {
177
- text: buffer.subarray(start, end).toString("utf8"),
178
- totalBytes,
179
- nextOffset: end < totalBytes ? end : null
180
- };
181
- }
182
- async function readConnectedDataArtifactBytes(args) {
183
- if (connectedDataArtifactOwnerId(args.artifactId) !== args.ownerId || connectedDataArtifactIsExpired(args.artifactId)) return null;
184
- const token = privateBlobToken();
185
- let buffer;
186
- if (token) {
187
- const { get } = await import("@vercel/blob");
188
- const result = await get(args.artifactId, { access: "private", token, useCache: false });
189
- if (!result || result.statusCode !== 200) return null;
190
- const streamed = await streamToBuffer(result.stream, args.maxBytes ?? 25 * 1024 * 1024);
191
- if (!streamed) return null;
192
- buffer = streamed;
193
- } else {
194
- if (isHosted()) return null;
195
- try {
196
- const path = join(localBaseDir(), "blobs", args.artifactId);
197
- const info = await stat(path);
198
- if (info.size > (args.maxBytes ?? 25 * 1024 * 1024)) return null;
199
- buffer = await readFile(path);
200
- } catch {
201
- return null;
202
- }
203
- }
204
- if (buffer.byteLength > (args.maxBytes ?? 25 * 1024 * 1024)) return null;
205
- return buffer;
206
- }
207
- async function cleanupExpiredConnectedDataArtifacts(args = {}) {
208
- const now = args.now ?? /* @__PURE__ */ new Date();
209
- const token = privateBlobToken();
210
- if (!token) return { deleted: 0, store: isHosted() ? "none" : "local" };
211
- if (!args.force && !(now.getUTCHours() === 3 && now.getUTCMinutes() === 17)) {
212
- return { deleted: 0, store: "private-vercel-blob", skipped: true };
213
- }
214
- const cutoff = now.getTime() - CONNECTED_DATA_ARTIFACT_TTL_MS;
215
- const { list, del } = await import("@vercel/blob");
216
- let cursor;
217
- let deleted = 0;
218
- for (let page = 0; page < 20; page++) {
219
- const result = await list({ prefix: CONNECTED_DATA_ARTIFACT_PREFIX, token, limit: 1e3, cursor });
220
- const expired = result.blobs.filter((blob) => new Date(blob.uploadedAt).getTime() <= cutoff);
221
- if (expired.length > 0) {
222
- await del(expired.map((blob) => blob.pathname), { token });
223
- deleted += expired.length;
224
- }
225
- if (!result.hasMore || !result.cursor) break;
226
- cursor = result.cursor;
227
- }
228
- return { deleted, store: "private-vercel-blob" };
229
- }
230
-
231
- export {
232
- CONNECTED_DATA_ARTIFACT_PREFIX,
233
- connectedDataArtifactOwnerId,
234
- createConnectedDataArtifact,
235
- createConnectedDataBinaryArtifact,
236
- renewConnectedDataArtifactDownload,
237
- readConnectedDataArtifactWindow,
238
- readConnectedDataArtifactBytes,
239
- cleanupExpiredConnectedDataArtifacts
240
- };