mcp-scraper 0.97.0 → 0.98.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 +5 -2425
- package/README.md +16 -412
- package/dist/bin/api-server.js +3 -2
- package/dist/bin/mcp-scraper-cli.js +33 -27
- package/dist/bin/mcp-scraper-core.js +9 -1
- package/dist/bin/mcp-scraper-install.js +17 -2
- package/dist/bin/mcp-stdio-server.js +9 -1
- package/dist/bin/paa-harvest.js +8 -1
- package/dist/index.cjs +5 -21830
- package/dist/index.d.ts +14 -607
- package/dist/index.js +5 -39
- package/dist/transport.d.ts +35 -0
- package/package.json +11 -51
- package/THIRD_PARTY_NOTICES.html +0 -203
- package/dist/actions-NCZNPYEY.js +0 -1
- package/dist/artifacts-4ZDNP2JW.js +0 -1
- package/dist/artifacts-N62OPIT5.js +0 -1
- package/dist/artifacts-PSADD5OC.js +0 -1
- package/dist/artifacts-RUR3OHAK.js +0 -1
- package/dist/blob-store-GIH26EDO.js +0 -1
- package/dist/bundle-XR6XKYJM.js +0 -1
- package/dist/chunk-24YDQ3EO.js +0 -5
- package/dist/chunk-3F7AFM53.js +0 -1
- package/dist/chunk-4HZXATHB.js +0 -27
- package/dist/chunk-4P3LZNVA.js +0 -954
- package/dist/chunk-4ZVO6GX4.js +0 -1
- package/dist/chunk-55ZANTHL.js +0 -3
- package/dist/chunk-63VWBMYR.js +0 -3
- package/dist/chunk-6FAMBNHY.js +0 -1
- package/dist/chunk-6N5EC7ZO.js +0 -1
- package/dist/chunk-7POHNTVW.js +0 -1
- package/dist/chunk-7SR7MEU5.js +0 -62
- package/dist/chunk-A4UASMEQ.js +0 -1
- package/dist/chunk-AMYPXA2F.js +0 -930
- package/dist/chunk-ANQ4JJVI.js +0 -71
- package/dist/chunk-B3JRL45T.js +0 -1
- package/dist/chunk-B4ZKPLSP.js +0 -1
- package/dist/chunk-B5Y26E3A.js +0 -1
- package/dist/chunk-C7MGJUTU.js +0 -1
- package/dist/chunk-CNSVZTTT.js +0 -13
- package/dist/chunk-EYGA6LOU.js +0 -1
- package/dist/chunk-GLCR4KJI.js +0 -21722
- package/dist/chunk-HCK6PLM3.js +0 -3
- package/dist/chunk-HNNYXMSI.js +0 -1
- package/dist/chunk-IFPION5D.js +0 -121
- package/dist/chunk-JMZIDHYQ.js +0 -2
- package/dist/chunk-JNPM3U3L.js +0 -189
- package/dist/chunk-K3VDGJNK.js +0 -1
- package/dist/chunk-KJQXUZ4Y.js +0 -4
- package/dist/chunk-KXJCGV3H.js +0 -1
- package/dist/chunk-M5QHXNFZ.js +0 -10
- package/dist/chunk-MVMWPKRC.js +0 -2
- package/dist/chunk-NALXKTUU.js +0 -1
- package/dist/chunk-ND4WIBXT.js +0 -16
- package/dist/chunk-NNOX3FYG.js +0 -198
- package/dist/chunk-NULRGHJ4.js +0 -41
- package/dist/chunk-OILOHQNL.js +0 -2
- package/dist/chunk-OLYPLX5C.js +0 -1
- package/dist/chunk-OOB3RKWD.js +0 -4
- package/dist/chunk-OSKCHEVM.js +0 -218
- package/dist/chunk-PD7BI7TR.js +0 -12
- package/dist/chunk-PKQHHCO4.js +0 -20
- package/dist/chunk-PQRT4T2G.js +0 -159
- package/dist/chunk-QER2ELZP.js +0 -1
- package/dist/chunk-RDHGQ2WZ.js +0 -1
- package/dist/chunk-SDQW7IJN.js +0 -1
- package/dist/chunk-SEZETSB3.js +0 -1
- package/dist/chunk-U3NV72AL.js +0 -8
- package/dist/chunk-U4WIJZCX.js +0 -1
- package/dist/chunk-UIOSADPB.js +0 -1718
- package/dist/chunk-UNEJYZ4T.js +0 -102
- package/dist/chunk-VVSHZV5S.js +0 -73
- package/dist/chunk-WHVK6FUB.js +0 -11
- package/dist/chunk-WNUXMPVX.js +0 -1
- package/dist/chunk-XYUJTIPE.js +0 -203
- package/dist/chunk-YJPFEL2E.js +0 -1
- package/dist/chunk-Z4EHBBL4.js +0 -41
- package/dist/contracts-GUXGFCVV.js +0 -1
- package/dist/core-schema-Y47YFKH2.js +0 -899
- package/dist/dispatch-ILBBKOSW.js +0 -1
- package/dist/editorial-reading-room/assets/app.js +0 -433
- package/dist/editorial-reading-room/assets/index.html +0 -139
- package/dist/editorial-reading-room/assets/styles.css +0 -1091
- package/dist/index.d.cts +0 -607
- package/dist/media-artifacts-67CJWI7O.js +0 -1
- package/dist/metering-YHZ46GV4.js +0 -1
- package/dist/migrations-3AKEC5QE.js +0 -1
- package/dist/queue-VOGXQDPR.js +0 -1
- package/dist/reconciliation-OXBG7JA2.js +0 -1
- package/dist/report-artifact-offload-6OOY2PTM.js +0 -1
- package/dist/repository-CYXVMYAI.js +0 -1
- package/dist/repository-UKDA4IWP.js +0 -1
- package/dist/server-6HUBN3OR.js +0 -5547
- package/dist/settlement-3PS32LQO.js +0 -1
- package/dist/worker-NXRU3TT3.js +0 -1
- package/public/.well-known/xray-install.json +0 -183
- package/public/agent-install.md +0 -200
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface PublicClientOptions {
|
|
2
|
+
apiKey?: string;
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
fetchImpl?: typeof fetch;
|
|
5
|
+
}
|
|
6
|
+
export interface RpcMessage {
|
|
7
|
+
jsonrpc?: string;
|
|
8
|
+
id?: string | number | null;
|
|
9
|
+
method?: string;
|
|
10
|
+
params?: Record<string, unknown>;
|
|
11
|
+
result?: unknown;
|
|
12
|
+
error?: unknown;
|
|
13
|
+
}
|
|
14
|
+
export interface ToolResult {
|
|
15
|
+
content: Array<{
|
|
16
|
+
type: string;
|
|
17
|
+
text?: string;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}>;
|
|
20
|
+
structuredContent?: Record<string, unknown>;
|
|
21
|
+
isError?: boolean;
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
}
|
|
24
|
+
/** Authenticated protocol transport. It never retries a possibly billable call. */
|
|
25
|
+
export declare class McpScraperClient {
|
|
26
|
+
#private;
|
|
27
|
+
readonly endpoint: string;
|
|
28
|
+
private readonly fetchImpl;
|
|
29
|
+
private protocolVersion?;
|
|
30
|
+
private nextId;
|
|
31
|
+
constructor(options?: PublicClientOptions);
|
|
32
|
+
relay(message: RpcMessage, onNotification?: (message: RpcMessage) => void, signal?: AbortSignal): Promise<RpcMessage | null>;
|
|
33
|
+
request<T = unknown>(method: string, params?: Record<string, unknown>): Promise<T>;
|
|
34
|
+
callTool(name: string, args?: Record<string, unknown>): Promise<ToolResult>;
|
|
35
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-scraper",
|
|
3
|
-
"
|
|
4
|
-
"description": "MCP server for MCP Scraper web intelligence tools",
|
|
3
|
+
"description": "Authenticated public client for hosted MCP Scraper tools and REST APIs",
|
|
5
4
|
"type": "module",
|
|
6
5
|
"main": "./dist/index.cjs",
|
|
7
6
|
"module": "./dist/index.js",
|
|
@@ -27,56 +26,17 @@
|
|
|
27
26
|
"engines": {
|
|
28
27
|
"node": ">=20.18.1"
|
|
29
28
|
},
|
|
29
|
+
"version": "0.98.0",
|
|
30
30
|
"license": "ISC",
|
|
31
|
-
"dependencies": {
|
|
32
|
-
"@anthropic-ai/sdk": "^0.96.0",
|
|
33
|
-
"@fal-ai/client": "^1.10.1",
|
|
34
|
-
"@hono/node-server": "^2.0.2",
|
|
35
|
-
"@libsql/client": "^0.17.3",
|
|
36
|
-
"@modelcontextprotocol/client": "^2.0.0",
|
|
37
|
-
"@modelcontextprotocol/node": "^2.0.0",
|
|
38
|
-
"@modelcontextprotocol/server": "^2.0.0",
|
|
39
|
-
"@neondatabase/serverless": "^1.1.0",
|
|
40
|
-
"@resvg/resvg-js": "^2.6.2",
|
|
41
|
-
"@vercel/blob": "^2.4.1",
|
|
42
|
-
"@vercel/functions": "^3.9.5",
|
|
43
|
-
"cheerio": "1.2.0",
|
|
44
|
-
"commander": "^12.0.0",
|
|
45
|
-
"diff": "^9.0.0",
|
|
46
|
-
"exceljs": "4.4.0",
|
|
47
|
-
"hono": "4.13.0",
|
|
48
|
-
"https-proxy-agent": "^7.0.6",
|
|
49
|
-
"ipaddr.js": "^1.9.1",
|
|
50
|
-
"jose": "^6.2.3",
|
|
51
|
-
"marked": "^18.0.7",
|
|
52
|
-
"mcpscraper-memory-tools": "2.0.0",
|
|
53
|
-
"p-limit": "^7.3.0",
|
|
54
|
-
"papaparse": "^5.4.0",
|
|
55
|
-
"pg": "^8.23.0",
|
|
56
|
-
"playwright": "^1.44.0",
|
|
57
|
-
"playwright-extra": "^4.3.6",
|
|
58
|
-
"puppeteer-extra-plugin-stealth": "^2.11.2",
|
|
59
|
-
"resend": "^6.12.3",
|
|
60
|
-
"satori": "^0.26.0",
|
|
61
|
-
"stripe": "^22.1.1",
|
|
62
|
-
"turndown": "^7.2.4",
|
|
63
|
-
"twilio": "^5.13.1",
|
|
64
|
-
"yauzl": "^3.4.0",
|
|
65
|
-
"yazl": "^3.3.1",
|
|
66
|
-
"youtube-transcript": "^1.3.1",
|
|
67
|
-
"zod": "4.4.3"
|
|
68
|
-
},
|
|
69
31
|
"files": [
|
|
70
|
-
"dist
|
|
71
|
-
"dist/*.cjs",
|
|
72
|
-
"dist/*.d.ts",
|
|
73
|
-
"dist/*.d.cts",
|
|
74
|
-
"dist/bin/*.js",
|
|
75
|
-
"dist/editorial-reading-room/assets",
|
|
76
|
-
"public/agent-install.md",
|
|
77
|
-
"public/.well-known/xray-install.json",
|
|
32
|
+
"dist",
|
|
78
33
|
"README.md",
|
|
79
|
-
"CHANGELOG.md"
|
|
80
|
-
|
|
81
|
-
|
|
34
|
+
"CHANGELOG.md"
|
|
35
|
+
],
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"commander": "^12.0.0"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
}
|
|
82
42
|
}
|
package/THIRD_PARTY_NOTICES.html
DELETED
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en"><meta charset="utf-8"><title>Third-party notices</title><body><h1>Browser control library</h1><p>This distribution bundles the browser control library with build-time minification and literal-name encoding. Its license follows.</p><pre> Apache License
|
|
3
|
-
Version 2.0, January 2004
|
|
4
|
-
http://www.apache.org/licenses/
|
|
5
|
-
|
|
6
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
-
|
|
8
|
-
1. Definitions.
|
|
9
|
-
|
|
10
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
-
|
|
13
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
-
the copyright owner that is granting the License.
|
|
15
|
-
|
|
16
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
-
other entities that control, are controlled by, or are under common
|
|
18
|
-
control with that entity. For the purposes of this definition,
|
|
19
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
-
direction or management of such entity, whether by contract or
|
|
21
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
-
|
|
24
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
-
exercising permissions granted by this License.
|
|
26
|
-
|
|
27
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
-
including but not limited to software source code, documentation
|
|
29
|
-
source, and configuration files.
|
|
30
|
-
|
|
31
|
-
"Object" form shall mean any form resulting from mechanical
|
|
32
|
-
transformation or translation of a Source form, including but
|
|
33
|
-
not limited to compiled object code, generated documentation,
|
|
34
|
-
and conversions to other media types.
|
|
35
|
-
|
|
36
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
-
Object form, made available under the License, as indicated by a
|
|
38
|
-
copyright notice that is included in or attached to the work
|
|
39
|
-
(an example is provided in the Appendix below).
|
|
40
|
-
|
|
41
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
-
form, that is based on (or derived from) the Work and for which the
|
|
43
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
-
of this License, Derivative Works shall not include works that remain
|
|
46
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
-
the Work and Derivative Works thereof.
|
|
48
|
-
|
|
49
|
-
"Contribution" shall mean any work of authorship, including
|
|
50
|
-
the original version of the Work and any modifications or additions
|
|
51
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
-
means any form of electronic, verbal, or written communication sent
|
|
56
|
-
to the Licensor or its representatives, including but not limited to
|
|
57
|
-
communication on electronic mailing lists, source code control systems,
|
|
58
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
-
excluding communication that is conspicuously marked or otherwise
|
|
61
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
-
|
|
63
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
-
subsequently incorporated within the Work.
|
|
66
|
-
|
|
67
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
-
Work and such Derivative Works in Source or Object form.
|
|
73
|
-
|
|
74
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
-
(except as stated in this section) patent license to make, have made,
|
|
78
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
-
where such license applies only to those patent claims licensable
|
|
80
|
-
by such Contributor that are necessarily infringed by their
|
|
81
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
-
institute patent litigation against any entity (including a
|
|
84
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
-
or contributory patent infringement, then any patent licenses
|
|
87
|
-
granted to You under this License for that Work shall terminate
|
|
88
|
-
as of the date such litigation is filed.
|
|
89
|
-
|
|
90
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
-
modifications, and in Source or Object form, provided that You
|
|
93
|
-
meet the following conditions:
|
|
94
|
-
|
|
95
|
-
(a) You must give any other recipients of the Work or
|
|
96
|
-
Derivative Works a copy of this License; and
|
|
97
|
-
|
|
98
|
-
(b) You must cause any modified files to carry prominent notices
|
|
99
|
-
stating that You changed the files; and
|
|
100
|
-
|
|
101
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
-
that You distribute, all copyright, patent, trademark, and
|
|
103
|
-
attribution notices from the Source form of the Work,
|
|
104
|
-
excluding those notices that do not pertain to any part of
|
|
105
|
-
the Derivative Works; and
|
|
106
|
-
|
|
107
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
-
distribution, then any Derivative Works that You distribute must
|
|
109
|
-
include a readable copy of the attribution notices contained
|
|
110
|
-
within such NOTICE file, excluding those notices that do not
|
|
111
|
-
pertain to any part of the Derivative Works, in at least one
|
|
112
|
-
of the following places: within a NOTICE text file distributed
|
|
113
|
-
as part of the Derivative Works; within the Source form or
|
|
114
|
-
documentation, if provided along with the Derivative Works; or,
|
|
115
|
-
within a display generated by the Derivative Works, if and
|
|
116
|
-
wherever such third-party notices normally appear. The contents
|
|
117
|
-
of the NOTICE file are for informational purposes only and
|
|
118
|
-
do not modify the License. You may add Your own attribution
|
|
119
|
-
notices within Derivative Works that You distribute, alongside
|
|
120
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
-
that such additional attribution notices cannot be construed
|
|
122
|
-
as modifying the License.
|
|
123
|
-
|
|
124
|
-
You may add Your own copyright statement to Your modifications and
|
|
125
|
-
may provide additional or different license terms and conditions
|
|
126
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
-
the conditions stated in this License.
|
|
130
|
-
|
|
131
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
-
this License, without any additional terms or conditions.
|
|
135
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
-
the terms of any separate license agreement you may have executed
|
|
137
|
-
with Licensor regarding such Contributions.
|
|
138
|
-
|
|
139
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
-
except as required for reasonable and customary use in describing the
|
|
142
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
-
|
|
144
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
-
implied, including, without limitation, any warranties or conditions
|
|
149
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
-
appropriateness of using or redistributing the Work and assume any
|
|
152
|
-
risks associated with Your exercise of permissions under this License.
|
|
153
|
-
|
|
154
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
-
unless required by applicable law (such as deliberate and grossly
|
|
157
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
-
liable to You for damages, including any direct, indirect, special,
|
|
159
|
-
incidental, or consequential damages of any character arising as a
|
|
160
|
-
result of this License or out of the use or inability to use the
|
|
161
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
-
other commercial damages or losses), even if such Contributor
|
|
164
|
-
has been advised of the possibility of such damages.
|
|
165
|
-
|
|
166
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
-
or other liability obligations and/or rights consistent with this
|
|
170
|
-
License. However, in accepting such obligations, You may act only
|
|
171
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
-
defend, and hold each Contributor harmless for any liability
|
|
174
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
-
of your accepting any such warranty or additional liability.
|
|
176
|
-
|
|
177
|
-
END OF TERMS AND CONDITIONS
|
|
178
|
-
|
|
179
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
-
|
|
181
|
-
To apply the Apache License to your work, attach the following
|
|
182
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
-
replaced with your own identifying information. (Don't include
|
|
184
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
-
comment syntax for the file format. We also recommend that a
|
|
186
|
-
file or class name and description of purpose be included on the
|
|
187
|
-
same "printed page" as the copyright notice for easier
|
|
188
|
-
identification within third-party archives.
|
|
189
|
-
|
|
190
|
-
Copyright 2026 Kernel
|
|
191
|
-
|
|
192
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
-
you may not use this file except in compliance with the License.
|
|
194
|
-
You may obtain a copy of the License at
|
|
195
|
-
|
|
196
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
-
|
|
198
|
-
Unless required by applicable law or agreed to in writing, software
|
|
199
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
-
See the License for the specific language governing permissions and
|
|
202
|
-
limitations under the License.
|
|
203
|
-
</pre></body></html>
|
package/dist/actions-NCZNPYEY.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{e as a,f as b,g as c,h as d,i as e,j as f,k as g,l as h}from"./chunk-Z4EHBBL4.js";import"./chunk-PQRT4T2G.js";import"./chunk-NALXKTUU.js";import"./chunk-OSKCHEVM.js";import"./chunk-RDHGQ2WZ.js";import"./chunk-U3NV72AL.js";import"./chunk-SEZETSB3.js";import"./chunk-SDQW7IJN.js";import"./chunk-VVSHZV5S.js";import"./chunk-4ZVO6GX4.js";import"./chunk-WNUXMPVX.js";import"./chunk-EYGA6LOU.js";import"./chunk-OILOHQNL.js";export{d as GMAIL_ATTACHMENT_REF_TTL_MS,c as GMAIL_INLINE_BODY_BYTES,b as GMAIL_MAIN_CONTRACT_HASH,a as GMAIL_MAIN_CONTRACT_VERSION,h as GmailService,e as GmailServiceError,g as normalizeGmailMessage,f as parseGmailAddresses};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"./chunk-RDHGQ2WZ.js";import"./chunk-SEZETSB3.js";import"./chunk-SDQW7IJN.js";import"./chunk-OILOHQNL.js";export{a as CONNECTED_DATA_ARTIFACT_PREFIX,b as CONNECTED_DATA_ARTIFACT_TTL_MS,c as CONNECTED_DATA_DOWNLOAD_TTL_MS,m as cleanupExpiredConnectedDataArtifacts,f as connectedDataArtifactExpiresAt,g as connectedDataArtifactIsExpired,e as connectedDataArtifactOwnerId,d as connectedDataArtifactPolicy,h as createConnectedDataArtifact,i as createConnectedDataBinaryArtifact,l as readConnectedDataArtifactBytes,k as readConnectedDataArtifactWindow,j as renewConnectedDataArtifactDownload};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d,e,f}from"./chunk-55ZANTHL.js";import"./chunk-SEZETSB3.js";import"./chunk-SDQW7IJN.js";import"./chunk-B3JRL45T.js";import"./chunk-OILOHQNL.js";export{a as MAPS_MEDIA_ARTIFACT_PREFIX,b as MAPS_MEDIA_ARTIFACT_TTL_MS,d as mapsMediaArtifactOwnerId,c as mapsMediaArtifactPolicy,f as packageMapsMedia,e as readOwnedMapsMediaArtifactBuffer};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-KXJCGV3H.js";import"./chunk-SEZETSB3.js";import"./chunk-SDQW7IJN.js";import"./chunk-OILOHQNL.js";export{a as SITE_EXTRACT_ARTIFACT_PREFIX,b as SITE_EXTRACT_ARTIFACT_TTL_MS,c as SITE_EXTRACT_DOWNLOAD_TTL_MS,o as cleanupExpiredSiteExtractArtifacts,f as createSiteExtractBundleArtifact,g as createSiteExtractBundleArtifactStream,i as createSiteExtractContentChunkArtifact,h as createSiteExtractImageArtifact,l as readOwnedSiteExtractArtifactBuffer,m as readOwnedSiteExtractContentChunk,n as readOwnedSiteExtractImageArtifact,k as readSiteExtractArtifactBuffer,j as renewSiteExtractArtifactDownload,e as siteExtractArtifactOwnerId,d as siteExtractArtifactPolicy};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j}from"./chunk-3F7AFM53.js";import"./chunk-SEZETSB3.js";import"./chunk-SDQW7IJN.js";import"./chunk-OILOHQNL.js";export{c as DIRECTORY_ARTIFACT_DOWNLOAD_TTL_MS,a as DIRECTORY_ARTIFACT_PREFIX,b as DIRECTORY_ARTIFACT_TTL_MS,d as DIRECTORY_CSV_CONTENT_TYPE,j as cleanupExpiredDirectoryArtifacts,g as createDirectoryCsvArtifact,f as directoryArtifactOwnerId,e as directoryArtifactPolicy,i as readDirectoryArtifactWindow,h as renewDirectoryArtifactDownload};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as a,o as b,p as c,q as d,r as e,s as f,t as g}from"./chunk-SDQW7IJN.js";export{g as cleanupPrivateBlobObjects,b as consumePrivateBlob,c as getPrivateBlob,a as metadataBlobId,d as putPrivateBlobFile,e as putPrivateBlobMetadata,f as signPrivateBlob};
|
package/dist/bundle-XR6XKYJM.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as b,k as c}from"./chunk-NULRGHJ4.js";import"./chunk-U4WIJZCX.js";import{F as a}from"./chunk-JNPM3U3L.js";import"./chunk-KXJCGV3H.js";import"./chunk-JMZIDHYQ.js";import"./chunk-M5QHXNFZ.js";import"./chunk-CNSVZTTT.js";import"./chunk-K3VDGJNK.js";import"./chunk-7SR7MEU5.js";import"./chunk-ANQ4JJVI.js";import"./chunk-SEZETSB3.js";import"./chunk-SDQW7IJN.js";import"./chunk-C7MGJUTU.js";import"./chunk-PKQHHCO4.js";import"./chunk-4ZVO6GX4.js";import"./chunk-WNUXMPVX.js";import"./chunk-OLYPLX5C.js";import"./chunk-B3JRL45T.js";import"./chunk-OILOHQNL.js";import"./chunk-HNNYXMSI.js";export{b as MAX_ANALYZED_LINK_EDGES,a as SITE_EXTRACT_PAGE_CHUNK,c as assembleExtractArtifacts};
|
package/dist/chunk-24YDQ3EO.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{a as S}from"./chunk-OLYPLX5C.js";import{a as P}from"./chunk-B3JRL45T.js";import{createHash as N}from"crypto";var k="3.0.0",x="analytics_setup_site",U="Install X-Ray",C="Install X-Ray and tell me what drives customers",m=`Call ${x} with { "startUrl": "<site URL>", "goal": "${C}" }; on every later call, reuse the returned setupId and revision.`,_=JSON.stringify({mcpServers:{"mcp-scraper":{command:"npx",args:["-y","--package","mcp-scraper@latest","mcp-scraper"],env:{MCP_SCRAPER_API_KEY:"${env:MCP_SCRAPER_API_KEY}"}}}},null,2),H=JSON.stringify({mcpServers:{"mcp-scraper":{url:"https://mcpscraper.dev/mcp"}}},null,2),I={schema:"https://mcpscraper.dev/schemas/xray-install-contract-v1.json",protocolVersion:k,product:"Thorbit X-Ray",triggerPhrases:[U,"Install X-Ray on this site and tell me what drives customers"],canonicalUrls:{markdown:"https://mcpscraper.dev/agent-install.md",json:"https://mcpscraper.dev/.well-known/xray-install.json",hostedMcp:"https://mcpscraper.dev/mcp"},facade:{tool:x,initialCall:{startUrl:"<site URL>",goal:C},continuationRule:"Treat setupId plus revision as the durable continuation handle. Reuse both after approval, runtime publication, verification, retry, or return."},topologies:{local_stdio:{label:"Local npm MCP process",authority:"The client starts MCP Scraper locally. After the one-time Pixel insertion, X-Ray setup publishes only owner-confirmed runtime configuration.",secretHandling:"Set MCP_SCRAPER_API_KEY in the local environment or client secret field. Never paste it into chat or commit it."},hosted_remote:{label:"Hosted authenticated MCP",authority:"The hosted MCP inspects approved public pages and publishes owner-confirmed X-Ray runtime configuration. It cannot read or write a caller-local path.",secretHandling:"Use the MCP OAuth/connection flow. Never put a credential in a URL, prompt, or config shown in chat."}},hosts:[{id:"codex",label:"Codex",supportedTopologies:["local_stdio","hosted_remote"],mcpConfigMode:"toml",workspaceRead:!0,workspaceWrite:!0,restartRequired:!0,exactConfig:`[mcp_servers.mcp-scraper]
|
|
2
|
-
command = "npx"
|
|
3
|
-
args = ["-y", "--package", "mcp-scraper@latest", "mcp-scraper"]
|
|
4
|
-
env_vars = ["MCP_SCRAPER_API_KEY"]`,continuation:m,rollback:"Remove the mcp_servers.mcp-scraper table, then restart Codex. Pixel removal is a separate owner-controlled site action."},{id:"claude-code",label:"Claude Code",supportedTopologies:["local_stdio","hosted_remote"],mcpConfigMode:"command",workspaceRead:!0,workspaceWrite:!0,restartRequired:!0,exactConfig:'claude mcp add mcp-scraper --scope user --env MCP_SCRAPER_API_KEY="$MCP_SCRAPER_API_KEY" -- npx -y --package mcp-scraper@latest mcp-scraper',continuation:m,rollback:"Run: claude mcp remove mcp-scraper -s user. Pixel removal is a separate owner-controlled site action."},{id:"claude-desktop",label:"Claude Desktop",supportedTopologies:["local_stdio"],mcpConfigMode:"desktop_extension",workspaceRead:!1,workspaceWrite:!1,restartRequired:!0,exactConfig:"Install https://mcpscraper.dev/downloads/mcp-scraper.mcpb and enter the API key only in Claude Desktop's protected configuration field.",continuation:m,rollback:"Remove the MCP Scraper extension in Claude Desktop. Pixel removal is a separate owner-controlled site action."},{id:"cursor",label:"Cursor",supportedTopologies:["local_stdio","hosted_remote"],mcpConfigMode:"json",workspaceRead:!0,workspaceWrite:!0,restartRequired:!0,exactConfig:_,continuation:m,rollback:"Remove mcp-scraper from .cursor/mcp.json (or the user MCP settings), then restart Cursor."},{id:"windsurf",label:"Windsurf",supportedTopologies:["local_stdio"],mcpConfigMode:"json",workspaceRead:!0,workspaceWrite:!0,restartRequired:!0,exactConfig:_,continuation:m,rollback:"Remove mcp-scraper from the Windsurf MCP configuration, then restart Windsurf."},{id:"cline",label:"Cline",supportedTopologies:["local_stdio"],mcpConfigMode:"json",workspaceRead:!0,workspaceWrite:!0,restartRequired:!0,exactConfig:_,continuation:m,rollback:"Remove mcp-scraper from Cline MCP Servers, then restart the extension host."},{id:"user-action-only",label:"User-action-only MCP host",supportedTopologies:["hosted_remote"],mcpConfigMode:"handoff_only",workspaceRead:!1,workspaceWrite:!1,restartRequired:!1,exactConfig:H,continuation:m,rollback:"Disconnect MCP Scraper from the host. Pixel removal remains an owner-controlled site action."}],tagBootstrap:{requirement:"one_global_pixel_once",ongoingConfiguration:"xray_runtime_manifest",sourceAccessRequiredAfterInstall:!1,supportedInsertionPaths:["manual","tag_manager","cms_plugin","coding_host"]},workflow:["Resolve Thorbit X-Ray entitlement and the target site without consuming MCP Scraper Credits.","Inspect the whole approved public site; enumerate distinct renderers, routes, and Pixel coverage.","Infer the business model and customer outcome, then propose one privacy-safe measurement plan.","If the Pixel is absent, return the canonical one-time tag and exact uncovered surfaces; do not claim ongoing control there.","Publish an approved measurement revision as a digest-bound runtime manifest; source or repository access is not required.","For SaaS, verify the measurement foundation: global tag coverage, ad-source capture, lifecycle events, currency and timezone, consent, and observed outcome events.","Optionally publish a structured post-purchase survey after approved disclosure evidence; reported influence remains separate from deterministic touches.","Compare observed attribution with customer-reported influence only with explicit weights totaling 1,000,000 micros and a named methodology version.","Keep view-through reporting unavailable until event-level provider evidence can join to an eligible X-Ray subject; aggregate impressions never qualify.","Verify route coverage, consent, PageViews, manifest convergence, bounded rule matches, and persisted definition/version evidence.","Require a separate exact-revision approval before any canary or real-visitor experiment activation.","Return first customer-journey answers when sufficient, or exact evidence-readiness thresholds when not.","On \u201Cimprove\u201D, propose one highest-value uncovered outcome, require approval when needed, and reverify."],safetyRules:["Never invent or hand-author tracking code; use the canonical product-authored Pixel snippet returned by analytics_setup_site.","Never ask for or print API keys, OAuth tokens, signed URLs, cookies, or other credentials.","Never call ad platforms directly or silently activate events, definitions, funnels, or delivery destinations.","Never treat a CTA click as a customer, sale, or revenue event without verified outcome evidence.","Never claim full-domain installation while an in-scope route or renderer is missing, excluded without approval, or unverifiable.","Never treat event-name presence as verification; require persisted definition ID and version evidence.","Never accept survey invitation tokens or exchange codes through MCP inputs or prompts.","Never treat customer-reported influence as identity, CRM mutation authority, ad-activation evidence, or a deterministic touch."],terminalStates:["complete","tag_required","input_required","approval_required","runtime_convergence_required","not_ready","error"]};function E(t){return Array.isArray(t)?`[${t.map(E).join(",")}]`:t&&typeof t=="object"?`{${Object.entries(t).sort(([e],[r])=>e.localeCompare(r)).map(([e,r])=>`${JSON.stringify(e)}:${E(r)}`).join(",")}}`:JSON.stringify(t)}function j(){return E(I)}var O=`sha256:${N("sha256").update(j(),"utf8").digest("hex")}`,L={...I,protocolDigest:O};function de(t){let e=L.hosts.find(r=>r.id===t);if(!e)throw new Error(`Unknown X-Ray host: ${t}`);return e}function me(){return["# Install X-Ray","",`Protocol: ${k} (${O})`,"",`Use ${x} as the single conversational setup facade. Ask for the target site URL if it is missing, then call it with the goal \u201C${C}\u201D.`,"","Continue the same setup with its setupId and revision. Confirm one global Pixel across all public rendering surfaces; present one measurement plan; publish it as a digest-bound runtime manifest after exact-revision approval; verify manifest and rule versions; then return first customer-journey answers or explicit readiness thresholds. For SaaS, verify the provider-neutral measurement foundation. Browser events never prove paid revenue. GitHub or repository access is not required after the tag is installed.","","Do not request pasted credentials, invent tracking code, silently activate measurement, call ad platforms directly, or claim customers/revenue from CTA clicks."].join(`
|
|
5
|
-
`)}function fe(t=L){return JSON.parse(JSON.stringify(t))}var q=20,D=20,W=10,z=20,w=280,Y=/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi,F=[".png",".jpg",".jpeg",".gif",".svg",".webp",".ico","@2x","sentry","wix.com","wixpress","example.","godaddy","squarespace","schema.org","u003e","core-js"],G=/\b(?:website|site|web)\s+(?:by|built|design(?:ed)?|develop(?:ed)?|powered)\b|\b(?:developer|webmaster)\b/i,J=/(?:^|\/)(?:about|bio|contact|contact-us|meet|our-team|people|profile|staff|team)(?:\/|$)/i,V={"facebook.com":"facebook","fb.com":"facebook","instagram.com":"instagram","linkedin.com":"linkedin","twitter.com":"twitter","x.com":"x","youtube.com":"youtube","youtu.be":"youtube","tiktok.com":"tiktok","pinterest.com":"pinterest"},K=/(?:\/shar(?:e|er)|\/intent\/|\/dialog\/|\/plugins\/|\/share\?|\/developers?\/|platform\.)/i;function R(t){return(t??"").replace(/\s+/g," ").trim()}function b(t,e){try{let r=new URL(t,e);return!["http:","https:"].includes(r.protocol)||r.username||r.password?null:r}catch{return null}}function g(t){let e=t;try{e=decodeURIComponent(t)}catch{}let r=e.split("?")[0].trim().toLowerCase().replace(/[),.;:]+$/,"");return r.length>254||r.split("@").length!==2||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9.-]+\.[a-z]{2,}$/i.test(r)||F.some(n=>r.includes(n))?null:r}function f(t){let e=t.closest("p,li,address,section,article,div").first();return R(e.length?e.text():t.text()).slice(0,w)}function X(t,e,r,n){let s=g(e);!s||G.test(n)||t.has(s)||t.set(s,{value:s,sourceUrl:r,context:R(n).slice(0,w),sourceType:"first_party_page"})}function B(t){t.hash="";for(let e of[...t.searchParams.keys()])/^(?:utm_|fbclid|gclid)/i.test(e)&&t.searchParams.delete(e);return t.href}function Z(t){let e=t.toLowerCase().replace(/^www\./,"");return Object.entries(V).find(([n])=>e===n||e.endsWith(`.${n}`))?.[1]??null}function Q(t,e){let r=b(e);if(!r)throw new Error("pageUrl must be a public HTTP(S) URL");let{$:n}=S(t),s=new Map,p=new Map,o=new Map,c=new Map;return n('a[href^="mailto:" i]').each((u,a)=>{let i=n(a);X(s,(i.attr("href")??"").slice(7),r.href,f(i))}),n("body").find("*").addBack().contents().filter((u,a)=>a.type==="text").each((u,a)=>{let i=n(a.parent??a),l=String(a.data??"");for(let d of l.match(Y)??[])X(s,d,r.href,f(i))}),n("a[href]").each((u,a)=>{let i=n(a),l=b(i.attr("href")??"",r.href);if(!l)return;let d=R(`${i.text()} ${f(i)}`).slice(0,w),T=Z(l.hostname);if(T&&!K.test(`${l.pathname}${l.search}`)){let v=B(l);p.has(v)||p.set(v,{url:v,network:T,sourceUrl:r.href,context:d});return}if(l.origin!==r.origin||!J.test(l.pathname))return;l.hash="";let y=l.href;c.has(y)||c.set(y,{url:y,sourceUrl:r.href,context:d})}),n("form").each((u,a)=>{let i=n(a),l=b(i.attr("action")||r.href,r.href);if(!l||l.origin!==r.origin)return;l.hash="";let d=l.href;o.has(d)||o.set(d,{url:d,sourceUrl:r.href,context:f(i)})}),{emails:[...s.values()].slice(0,q),socialProfiles:[...p.values()].slice(0,D),contactForms:[...o.values()].slice(0,W),candidatePageUrls:[...c.values()].slice(0,z)}}var ee=new Set(["admin","contact","customerservice","hello","help","info","inquiries","mail","office","reception","sales","service","support","team"]),te=/(?:^|\/)(?:about|bio|contact|contact-us|meet|our-team|people|profile|staff|team)(?:\/|$)/i,re=/\b(?:our team|meet the team|staff|agents?|brokers?|realtors?|people)\b/i,oe=/\b(?:brokerage|company|corporate|front desk|main office|office|organization|reception)\b/i;function M(t){return t.toLowerCase().replace(/[^a-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean)}function A(t,e){try{let r=new URL(t,e);return!["http:","https:"].includes(r.protocol)||r.username||r.password?null:r}catch{return null}}function ne(t,e){let r=t.value.split("@")[0].toLowerCase().replace(/[^a-z0-9]+/g," "),n=M(e.name).filter(a=>a.length>1),s=A(t.sourceUrl)?.pathname.toLowerCase()??"",p=`${t.context} ${s}`.toLowerCase(),o=ee.has(r.replace(/\s+/g,"")),c=n.filter(a=>new RegExp(`(?:^|[^a-z0-9])${a}(?:$|[^a-z0-9])`,"i").test(`${r} ${p}`)).length,u=e.entityType==="person"&&n.length>=2&&c>=Math.min(2,n.length)&&(r.includes(n[0])||s.includes(n.join("-"))||s.includes(n.join("/")));return!o&&u?{scope:"person",reasons:["named_person_page_context"]}:o||oe.test(p)?{scope:"office",reasons:o?["generic_mailbox_prefix"]:["organization_page_context"]}:re.test(p)?{scope:"team",reasons:["team_page_context"]}:e.entityType==="business"&&M(e.organization||e.name).filter(i=>i.length>2).some(i=>p.includes(i))?{scope:"team",reasons:["business_context"]}:{scope:"unknown",reasons:["public_occurrence_without_identity_evidence"]}}function ve(t,e){let r=t.map(o=>({...o,...ne(o,e)})),n=e.entityType==="person"?["person","team"]:["person","team","office"],s=["provided","first_party_page","structured_data","serp_snippet"],p=["person","team","office"];return r.filter(o=>n.includes(o.scope)).sort((o,c)=>s.indexOf(o.sourceType)-s.indexOf(c.sourceType)||p.indexOf(o.scope)-p.indexOf(c.scope))[0]??null}function _e(t,e,r){if(!Number.isInteger(r)||r<1||r>4)throw new Error("maxPages must be an integer from 1 to 4");let n=A(t);if(!n)return[];n.hash="";let s=new Set([n.href]),p=e.map(o=>typeof o=="string"?o:o.url).map(o=>A(o,n.href)).filter(o=>!!(o&&o.origin===n.origin&&te.test(o.pathname)));for(let o of p)o.hash="",s.add(o.href);for(let o of["/contact","/contact-us"])s.add(new URL(o,n.origin).href);return[...s].slice(0,r)}var se=/[A-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi,ie=/\b(?:website|site|web)\s+(?:by|built|design(?:ed)?|develop(?:ed)?|powered)\b|\b(?:developer|webmaster)\b/i,ae=280,ce=10;function h(t){return t.toLowerCase().replace(/^www\./,"").replace(/\.$/,"")}function le(t){let e=h(t);return e==="localhost"||e.endsWith(".localhost")||e.endsWith(".local")||!e.includes(".")&&!e.includes(":")}function $(t){try{let e=new URL(t.trim());return!["http:","https:"].includes(e.protocol)||e.username||e.password||le(e.hostname)||P(e.hostname)?null:e}catch{return null}}function pe(t,e){return`${t} ${e??""}`.replace(/\s+/g," ").trim().slice(0,ae)}function we(t){let e=$(t);return e?(e.hostname=h(e.hostname),`email for ${e.protocol}//${e.host}/`):null}function Re({websiteUrl:t,results:e}){let r=$(t);if(!r)return[];let n=h(r.hostname),s=new Map,p=e.map((o,c)=>({result:o,index:c})).sort((o,c)=>{let u=Number.isFinite(o.result.position)?o.result.position:Number.MAX_SAFE_INTEGER,a=Number.isFinite(c.result.position)?c.result.position:Number.MAX_SAFE_INTEGER;return u-a||o.index-c.index});for(let{result:o}of p){let c=`${o.title} ${o.snippet??""}`,u=pe(o.title,o.snippet);for(let a of c.match(se)??[]){let i=g(a);!i||ie.test(c)||h(i.slice(i.lastIndexOf("@")+1))!==n||s.has(i)||s.set(i,{value:i,sourceUrl:o.url,sourceTitle:o.title,sourcePosition:o.position,context:u,sourceType:"serp_snippet"})}}return[...s.values()].slice(0,ce)}export{Q as a,ne as b,ve as c,_e as d,we as e,Re as f,k as g,x as h,C as i,O as j,L as k,de as l,me as m,fe as n};
|
package/dist/chunk-3F7AFM53.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{e as u,h as p,i as T}from"./chunk-SEZETSB3.js";import{i as d}from"./chunk-SDQW7IJN.js";var c="directory-workflows/",w=10080*60*1e3,y=900*1e3,A="text/csv; charset=utf-8";function E(){return process.env.DIRECTORY_ARTIFACT_READ_WRITE_TOKEN?.trim()||process.env.PRIVATE_ARTIFACT_READ_WRITE_TOKEN?.trim()||process.env.CONNECTED_DATA_READ_WRITE_TOKEN?.trim()||process.env.CONNECTED_DATA_BLOB_READ_WRITE_TOKEN?.trim()||null}function C(){return process.env.VERCEL==="1"||process.env.NODE_ENV==="production"}function a(){return{prefix:c,artifactTtlMs:w,downloadTtlMs:y,token:E()}}function I(t){return`${t.trim().replace(/\.csv$/i,"")||"directory-workflow"}.csv`}function R(t){return d(t,c)}async function b(t){if(!Number.isSafeInteger(t.rowCount)||t.rowCount<0)throw new Error("directory artifact rowCount must be a non-negative safe integer");return{...await u({policy:a(),ownerId:t.ownerId,artifactKey:`${t.jobId}.csv`,createdAt:t.createdAt,filename:I(t.filename),contentType:A,content:t.csv}),contentType:A,rowCount:t.rowCount}}async function P(t){return p({policy:a(),artifactId:t.artifactId,ownerId:t.ownerId})}async function O(t,e,r){return T({policy:a(),artifactId:t,offset:e,maxBytes:r})}async function x(t={}){let e=t.now??new Date,r=E();if(!r)return{deleted:0,store:C()?"none":"local"};if(!t.force&&!(e.getUTCHours()===3&&e.getUTCMinutes()===19))return{deleted:0,store:"private-vercel-blob",skipped:!0};let _=e.getTime()-w,{list:v,del:m}=await import("@vercel/blob"),s,f=0;for(let l=0;l<20;l+=1){let n=await v({prefix:c,token:r,limit:1e3,cursor:s}),o=n.blobs.filter(i=>new Date(i.uploadedAt).getTime()<=_);if(o.length>0&&(await m(o.map(i=>i.pathname),{token:r}),f+=o.length),!n.hasMore||!n.cursor)break;s=n.cursor}return{deleted:f,store:"private-vercel-blob"}}export{c as a,w as b,y as c,A as d,a as e,R as f,b as g,P as h,O as i,x as j};
|
package/dist/chunk-4HZXATHB.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import{c as ke}from"./chunk-KJQXUZ4Y.js";import{a as _e}from"./chunk-6N5EC7ZO.js";import{a as be,c as Re,d as ee,e as Se,f as xe}from"./chunk-24YDQ3EO.js";import{c as F}from"./chunk-OILOHQNL.js";import{z as c}from"zod";import{z as Ze}from"zod";var Ce=Ze.enum(["core","hours","services","areasServed","reviews","images","all"]);function Et(e){let t=new Set(e.include??[]),n=t.has("all");return{includeReviews:e.includeReviews||n||t.has("reviews"),includeServices:e.includeServices||n||t.has("services")||t.has("areasServed"),includeImages:e.includeImages||n||t.has("images")}}function It(){return process.env.MAPS_BROWSER_PROVIDER?.trim().toLowerCase()==="\u0062\u0072\u0069\u0067\u0068\u0074_\u0064\u0061\u0074\u0061"?"\u0062\u0072\u0069\u0067\u0068\u0074_\u0064\u0061\u0074\u0061":"\u006b\u0065\u0072\u006e\u0065\u006c"}var O="none",Ot=c.object({businessName:c.string().min(1),location:c.string().min(1),gl:c.string().length(2).default("us"),hl:c.string().length(2).default("en"),includeReviews:c.boolean().default(!1),maxReviews:c.number().int().min(1).max(1e3).default(50),includeServices:c.boolean().default(!1),includeImages:c.boolean().default(!1),include:c.array(Ce).optional(),imageScope:c.enum(["owner","all"]).default("all"),maxImages:c.number().int().min(1).max(250).default(100),maxInlineImages:c.number().int().min(0).max(5).default(3),\u006b\u0065\u0072\u006e\u0065\u006cApiKey:c.string().optional(),\u006b\u0065\u0072\u006e\u0065\u006cProxyId:c.string().optional(),headless:c.boolean().default(!0)}),qt=c.object({query:c.string().min(1),location:c.string().optional(),gl:c.string().length(2).default("us"),hl:c.string().length(2).default("en"),maxResults:c.number().int().min(1).max(50).default(10),includeServices:c.boolean().default(!1),proxyMode:c.enum(["location","configured","none"]).default(O),proxyZip:c.string().regex(/^\d{5}$/).optional(),serpRedirect:c.boolean().optional(),forceDirectEgress:c.boolean().optional(),debug:c.boolean().default(!1),\u006b\u0065\u0072\u006e\u0065\u006cApiKey:c.string().optional(),\u006b\u0065\u0072\u006e\u0065\u006cProxyId:c.string().optional(),\u006b\u0065\u0072\u006e\u0065\u006cProxyResolution:c.unknown().optional(),headless:c.boolean().default(!0)}),Tt=c.object({name:c.string().nullable(),rating:c.string().nullable(),reviewCount:c.string().nullable(),category:c.string().nullable(),address:c.string().nullable(),hoursSummary:c.string().nullable(),phone:c.string().nullable(),phoneDisplay:c.string().nullable(),website:c.string().nullable(),plusCode:c.string().nullable(),bookingUrl:c.string().nullable()}),jt=c.object({day:c.string(),hours:c.string()}),Ut=c.object({reviewHistogram:c.array(c.object({stars:c.number(),count:c.string()})),reviewTopics:c.array(c.object({label:c.string(),count:c.string()}))}),Ht=c.object({reviewId:c.string(),author:c.string().nullable(),stars:c.string().nullable(),date:c.string().nullable(),text:c.string().nullable(),ownerResponse:c.string().nullable(),reviewExpansionIncomplete:c.boolean().optional()}),Bt=c.object({section:c.string(),attribute:c.string()});import{mkdir as J,readFile as et,stat as tt,writeFile as V}from"fs/promises";import{existsSync as rt}from"fs";import{platform as nt}from"os";import{dirname as te,join as N}from"path";import{execFile as it}from"child_process";function Ae(e){return e.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"")}function Pe(){return new Date().toISOString().replace(/[:.]/g,"-")}function le(e){return Ae(e).replace(/^-+|-+$/g,"").slice(0,80)||"run"}var G=class e{constructor(t,n,r,i,s,a,u){this.workflowId=t;this.title=n;this.runId=r;this.baseDir=i;this.runDir=s;this.startedAt=a;this.input=u}workflowId;title;runId;baseDir;runDir;startedAt;input;artifacts=[];static async create(t,n,r,i,s){let a=new Date().toISOString(),u=s?.trim()||`${Pe()}-${le(t)}-${Math.random().toString(36).slice(2,8)}`,l=String(r.keyword??r.query??r.domain??r.state??t),d=F(i),m=N(d,"workflows",t,`${Pe()}-${le(l)}-${le(u).slice(0,20)}`);return await J(m,{recursive:!0}),new e(t,n,u,d,m,a,r)}async remember(t,n,r,i){let s=await tt(r).then(a=>a.size).catch(()=>{});return this.artifacts.push({kind:t,label:n,path:r,bytes:s,rows:i}),await _e({title:`${this.title} ${n}`,content:`artifact: ${r}`,source:`mcp-scraper-workflow:${this.workflowId}:${this.runId}`}),r}async writeJson(t,n,r){let i=N(this.runDir,n);return await J(te(i),{recursive:!0}),await V(i,JSON.stringify(r,null,2),"utf8"),this.remember("json",t,i)}async writeText(t,n,r,i="markdown"){let s=N(this.runDir,n);return await J(te(s),{recursive:!0}),await V(s,r,"utf8"),this.remember(i,t,s)}async writeCsv(t,n,r,i){let s=N(this.runDir,n);return await J(te(s),{recursive:!0}),await V(s,ke(r,i),"utf8"),this.remember("csv",t,s,i.length)}async writeHtml(t,n,r){return this.writeText(t,n,r,"html_report")}async writeManifest(t,n,r,i){let s={workflow:this.workflowId,title:this.title,runId:this.runId,status:t,startedAt:this.startedAt,completedAt:t==="running"?null:new Date().toISOString(),input:this.input,artifacts:this.artifacts,warnings:r,errors:i,counts:n},a=N(this.runDir,"manifest.json");return await V(a,JSON.stringify(s,null,2),"utf8"),await ot(s,a,this.baseDir),a}};function $e(e=F()){return N(e,"workflows","index.json")}async function Me(e){let t=$e(e);if(!rt(t))return{runs:[]};try{return JSON.parse(await et(t,"utf8"))}catch{return{runs:[]}}}async function ot(e,t,n){if(e.status==="running")return;let r=$e(n),i=await Me(n),s=e.artifacts.find(u=>u.kind==="html_report")?.path??null,a={workflow:e.workflow,runId:e.runId,status:e.status,startedAt:e.startedAt,reportPath:s,manifestPath:t,summary:`${e.title} (${e.status})`};i.runs=[a,...i.runs.filter(u=>u.runId!==e.runId)].slice(0,200),await J(te(r),{recursive:!0}),await V(r,JSON.stringify(i,null,2),"utf8")}async function Ee(e){return(await Me(F(e))).runs}async function Ie(e,t){let n=await Ee(t);return e==="last"?n[0]??null:n.find(r=>r.runId===e)??null}async function st(e,t){let n=await Ie(e,t);if(!n?.reportPath)throw new Error(`No report found for "${e}"`);return nt()==="darwin"&&await new Promise((r,i)=>{it("open",[n.reportPath],s=>s?i(s):r())}),n.reportPath}import{readFile as $t}from"fs/promises";import{z as Er}from"zod";var Q=class{constructor(t,n,r=fetch,i={}){this.apiUrl=t;this.apiKey=n;this.fetchImpl=r;this.extraHeaders=i}apiUrl;apiKey;fetchImpl;extraHeaders;async post(t,n,r=18e4){let i=await this.fetchImpl(`${this.apiUrl.replace(/\/$/,"")}${t}`,{method:"POST",headers:{...this.extraHeaders,"Content-Type":"application/json","x-api-key":this.apiKey},body:JSON.stringify(n),signal:AbortSignal.timeout(r)}),s=await i.json().catch(()=>({}));if(!i.ok){let a=typeof s.error=="string"?s.error:`Workflow API ${t} failed with ${i.status}`;throw new Error(a)}return s}};import{z as q}from"zod";function D(e){return String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function at(e){let t=e.rows.map(n=>`<tr>${e.columns.map(r=>`<td>${D(n[r])}</td>`).join("")}</tr>`).join(`
|
|
2
|
-
`);return["<section>",`<h2>${D(e.title)}</h2>`,'<div class="table-wrap"><table>',`<thead><tr>${e.columns.map(n=>`<th>${D(n)}</th>`).join("")}</tr></thead>`,`<tbody>${t||`<tr><td colspan="${e.columns.length}">No rows</td></tr>`}</tbody>`,"</table></div>","</section>"].join(`
|
|
3
|
-
`)}function $(e){let t=e.warnings?.length?`<section class="warnings"><h2>Warnings</h2><ul>${e.warnings.map(i=>`<li>${D(i)}</li>`).join("")}</ul></section>`:"",n=(e.sections??[]).map(i=>`<section><h2>${D(i.title)}</h2><p>${D(i.body)}</p></section>`).join(`
|
|
4
|
-
`),r=(e.tables??[]).map(at).join(`
|
|
5
|
-
`);return["<!doctype html>",'<html lang="en">',"<head>",'<meta charset="utf-8">','<meta name="viewport" content="width=device-width, initial-scale=1">',`<title>${D(e.title)}</title>`,"<style>",':root{font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:#172026;background:#f6f7f8}',"body{margin:0;padding:32px}main{max-width:1180px;margin:0 auto;background:#fff;border:1px solid #d9dee3;border-radius:8px;padding:28px}","h1{font-size:30px;line-height:1.15;margin:0 0 8px}h2{font-size:18px;margin:28px 0 12px}p{line-height:1.55;color:#3d4952}.sub{color:#66737f;margin:0 0 20px}",".summary{background:#eef6f8;border-left:4px solid #12829a;padding:14px 16px;margin:20px 0}.warnings{background:#fff7e8;border-left:4px solid #c87b00;padding:12px 16px}",".table-wrap{overflow:auto;border:1px solid #dfe5ea;border-radius:8px}table{border-collapse:collapse;width:100%;font-size:13px}th,td{border-bottom:1px solid #edf0f2;padding:9px 10px;text-align:left;vertical-align:top}th{background:#f3f5f7;color:#31404c;position:sticky;top:0}tr:last-child td{border-bottom:0}","</style>","</head>","<body><main>",`<h1>${D(e.title)}</h1>`,e.subtitle?`<p class="sub">${D(e.subtitle)}</p>`:"",`<div class="summary">${D(e.summary)}</div>`,t,n,r,"</main></body></html>"].join(`
|
|
6
|
-
`)}var lt=q.object({keyword:q.string().min(1),domain:q.string().optional(),location:q.string().optional(),maxQuestions:q.number().int().min(1).max(100).default(40),includeSerp:q.boolean().default(!0),includePaa:q.boolean().default(!0),includeAiOverview:q.boolean().default(!0),returnPartial:q.boolean().default(!0)});function K(e){if(!e)return null;try{return new URL(e.includes("://")?e:`https://${e}`).hostname.replace(/^www\./,"").toLowerCase()}catch{return e.replace(/^https?:\/\//,"").replace(/^www\./,"").split("/")[0]?.toLowerCase()||null}}function ce(e){return K(e)??""}function ct(e,t,n){let r=K(e.domain),i=[];for(let s of t?.organicResults??[]){let a=K(s.domain)??ce(s.url);i.push({surface:"organic",position:s.position,title:s.title,url:s.url,domain:a,question:"",answer_excerpt:s.snippet??"",is_target:r?a===r:!1,is_competitor:r?a!==r:!0})}for(let s of n?.flat??[]){let a=s.source_cite??"",u=K(s.source_site??"")??(a?ce(a):"");i.push({surface:"paa",position:"",title:s.source_title??s.source_site??"",url:a,domain:u,question:s.question,answer_excerpt:(s.answer??"").slice(0,240),is_target:r?u===r:!1,is_competitor:r?!!(u&&u!==r):!!u})}for(let[s,a]of(t?.aiOverview?.citations??[]).entries()){let u=a.href??"",l=u?ce(u):"";i.push({surface:"ai_overview",position:s+1,title:a.text??"",url:u,domain:l,question:"",answer_excerpt:"",is_target:r?l===r:!1,is_competitor:r?!!(l&&l!==r):!!l})}return i}function ut(e,t){let n=new Map;for(let r of e){let i=String(r.domain??"");if(!i||i===t)continue;let s=n.get(i)??{organic:[],paa:0,ai:0,urls:new Set};r.surface==="organic"&&r.position&&s.organic.push(Number(r.position)),r.surface==="paa"&&(s.paa+=1),r.surface==="ai_overview"&&(s.ai+=1),r.url&&s.urls.add(String(r.url)),n.set(i,s)}return[...n.entries()].map(([r,i])=>({domain:r,organic_best_position:i.organic.length?Math.min(...i.organic):"",organic_count:i.organic.length,paa_mentions:i.paa,ai_overview_citations:i.ai,source_url_count:i.urls.size})).sort((r,i)=>Number(r.organic_best_position||999)-Number(i.organic_best_position||999))}var We={id:"agent-packet",title:"Agent-Ready SEO Packet",description:"Create an evidence folder for AI agents from live SERP/PAA/AI search surfaces.",inputSchema:lt,createState:()=>({serp:null,paa:null,warnings:[]}),steps:[{id:"harvest-serp",title:"Harvest organic SERP + AI Overview",async run({input:e,state:t,ctx:n}){if(!e.includeSerp)return{state:t,output:{skipped:!0,reason:"includeSerp is false"}};try{let r=await n.client.post("/harvest/sync",{query:e.keyword,location:e.location,serpOnly:!0,includeAllSerpFeatures:!0,maxQuestions:1,format:"json"},62e4);return await n.artifacts.writeJson("SERP raw JSON","raw/serp.json",r),{state:{...t,serp:r},output:{organicResults:r.organicResults?.length??0,localPack:r.localPack?.length??0,aiOverviewDetected:!!r.aiOverview?.detected,aiOverviewCitations:r.aiOverview?.citations?.length??0}}}catch(r){let i=`SERP evidence unavailable: ${r instanceof Error?r.message:String(r)}`;return{state:{...t,warnings:[...t.warnings,i]},output:{error:i},warnings:[i]}}}},{id:"harvest-paa",title:"Harvest People Also Ask",async run({input:e,state:t,ctx:n}){if(!e.includePaa)return{state:t,output:{skipped:!0,reason:"includePaa is false"}};try{let r=await n.client.post("/harvest/sync",{query:e.keyword,location:e.location,maxQuestions:e.maxQuestions,format:"json"},735e3);return await n.artifacts.writeJson("PAA raw JSON","raw/paa.json",r),{state:{...t,paa:r},output:{paaQuestions:r.flat?.length??0}}}catch(r){let i=`PAA evidence unavailable: ${r instanceof Error?r.message:String(r)}`;return{state:{...t,warnings:[...t.warnings,i]},output:{error:i},warnings:[i]}}}},{id:"assemble",title:"Assemble evidence packet",async run({input:e,state:t,ctx:n}){let{serp:r,paa:i}=t,s=t.warnings;if(!r&&!i&&!e.returnPartial)throw new Error("No SEO evidence was collected");let a=ct(e,r,i),u=K(e.domain),l=ut(a,u),d={input:e,serp:r??{status:"skipped"},paa:i??{status:"skipped"},target:{domain:u,organicPositions:a.filter(g=>g.surface==="organic"&&g.is_target).map(g=>Number(g.position)),citedInAiOverview:a.some(g=>g.surface==="ai_overview"&&g.is_target),citedInPaa:a.some(g=>g.surface==="paa"&&g.is_target)},competitors:l,warnings:s};await n.artifacts.writeJson("Evidence JSON","evidence.json",d),await n.artifacts.writeCsv("Sources CSV","sources.csv",["surface","position","title","url","domain","question","answer_excerpt","is_target","is_competitor"],a),await n.artifacts.writeCsv("Competitors CSV","competitors.csv",["domain","organic_best_position","organic_count","paa_mentions","ai_overview_citations","source_url_count"],l);let m=[`# SEO Evidence Brief: ${e.keyword}`,"",`Location: ${e.location??"not specified"}`,`Target domain: ${u??"not specified"}`,"","## Evidence Summary",`- Organic rows: ${a.filter(g=>g.surface==="organic").length}`,`- PAA rows: ${a.filter(g=>g.surface==="paa").length}`,`- AI Overview citations: ${a.filter(g=>g.surface==="ai_overview").length}`,`- Competitor domains: ${l.length}`,"","## Recommended Use","Use the CSV files as source of truth. Tie content recommendations to evidence rows and mark unsupported ideas as assumptions."].join(`
|
|
7
|
-
`);await n.artifacts.writeText("Brief","brief.md",m),await n.artifacts.writeText("Agent tasks","tasks.md",["# Agent Tasks","","- [ ] Read `evidence.json` before writing recommendations.","- [ ] Compare the target domain against `competitors.csv`.","- [ ] Use `sources.csv` for citations and source-grounded page sections.","- [ ] Mark unsupported recommendations as assumptions."].join(`
|
|
8
|
-
`)),await n.artifacts.writeText("Agent instructions","agent-instructions.md",["# Agent Instructions","","You are working from an MCP Scraper SEO evidence packet. Use `evidence.json` and CSV files as source of truth. Do not invent citations. If a recommendation is not supported by evidence, mark it as an assumption."].join(`
|
|
9
|
-
`));let f=`${a.length} evidence rows and ${l.length} competitor domains collected.`,_=await n.artifacts.writeHtml("HTML report","report.html",$({title:"Agent-Ready SEO Packet",subtitle:`${e.keyword}${e.location?` \xB7 ${e.location}`:""}`,summary:f,warnings:s,tables:[{title:"Competitor Domains",columns:["domain","organic_best_position","organic_count","paa_mentions","ai_overview_citations","source_url_count"],rows:l.slice(0,50)},{title:"Evidence Sources",columns:["surface","position","title","domain","question","is_target"],rows:a.slice(0,100)}]})),h=s.length?"partial":"succeeded",k={sources:a.length,competitors:l.length};return await n.artifacts.writeManifest(h,k,s,[]),{state:t,output:{sources:a.length,competitors:l.length,status:h},summary:{title:"Agent-Ready SEO Packet",summary:f,status:h,counts:k,warnings:s,errors:[],reportPath:_}}}}]};import{z as T}from"zod";var mt=T.object({query:T.string().min(1),state:T.string().min(2).default("TN"),minPopulation:T.number().int().min(0).default(1e5),maxCities:T.number().int().min(1).max(100).default(25),maxResultsPerCity:T.number().int().min(1).max(50).default(20),concurrency:T.number().int().min(1).max(5).default(5),proxyMode:T.enum(["configured","none"]).default(O),saveCsv:T.boolean().default(!0)});function Y(e){let t=[];for(let n of e.cities){if(!n.results.length){t.push({source_query:e.query,source_location:n.location,city:n.city,state:n.state,population:n.population,result_position:null,business_name:null,review_stars:null,review_count:null,category:null,address:null,phone:null,website_url:null,place_url:null,cid:null,cid_decimal:null,result_status:n.status,error:n.error});continue}for(let r of n.results)t.push({source_query:e.query,source_location:n.location,city:n.city,state:n.state,population:n.population,result_position:r.position,business_name:r.name,review_stars:r.rating,review_count:r.reviewCount,category:r.category,address:r.address,phone:r.phone,website_url:r.websiteUrl,place_url:r.placeUrl,cid:r.cid,cid_decimal:r.cidDecimal,result_status:n.status,error:n.error})}return t}var X=["source_query","source_location","city","state","population","result_position","business_name","review_stars","review_count","category","address","phone","website_url","place_url","cid","cid_decimal","result_status","error"],De={id:"directory",title:"Directory Workflow",description:"Select city markets and export Google Maps business candidates.",inputSchema:mt,async run(e,t){await t.artifacts.writeManifest("running",{},[],[]);let n=await t.client.post("/directory/run",{...e,background:!1},9e5);await t.artifacts.writeJson("Directory evidence","evidence.json",n);let r=Y(n);await t.artifacts.writeCsv("Directory CSV","exports/directory.csv",X,r);let i=n.cities.map(m=>({city:m.city,state:m.state,population:m.population,status:m.status,result_count:m.resultCount,error:m.error??""})),s=r.filter(m=>m.business_name).slice(0,100).map(m=>({city:m.city,position:m.result_position,business:m.business_name,rating:m.review_stars,reviews:m.review_count,category:m.category,website:m.website_url})),a=`${n.selectedCityCount} cities processed with ${n.totalResultCount} Maps results.`;await t.artifacts.writeText("Summary","summary.md",`# Directory Workflow
|
|
10
|
-
|
|
11
|
-
${a}
|
|
12
|
-
`);let u=await t.artifacts.writeHtml("HTML report","report.html",$({title:"Directory Workflow",subtitle:`${e.query} \xB7 ${e.state}`,summary:a,warnings:n.warnings,tables:[{title:"Cities",columns:["city","state","population","status","result_count","error"],rows:i},{title:"Top Results",columns:["city","position","business","rating","reviews","category","website"],rows:s}]})),l=n.cities.some(m=>m.status==="failed")?"partial":"succeeded",d={cities:n.selectedCityCount,results:n.totalResultCount,rows:r.length};return await t.artifacts.writeManifest(l,d,n.warnings,[]),{title:"Directory Workflow",summary:a,status:l,counts:d,warnings:n.warnings,errors:[],reportPath:u}}};import{z as j}from"zod";var pt=j.object({query:j.string().min(1).describe('Business category, niche, or keyword to search on Google Maps, e.g. "roofers", "med spas", "dentists". Do not include the city here.'),location:j.string().min(1).describe('City / market to search, e.g. "Houston, TX" or "Austin, Texas".'),maxResults:j.number().int().min(1).max(50).default(25).describe("How many Maps businesses to collect for the market. Maximum 50."),enrichWebsites:j.boolean().default(!0).describe("Visit each business website (home + contact pages) to harvest email and social links. Uses the proxy/browser-backed extractor so blocked sites still resolve."),emailSearchFallback:j.enum(["off","serp_snippets"]).default("off").describe("After bounded website extraction finds no email, optionally run one billed SERP lookup and retain exact-domain public email occurrences from result titles/snippets."),hydrateReviewCounts:j.boolean().default(!0).describe("Deep-dive each profile to confirm the review count and booking URL that the Maps search list omits."),concurrency:j.number().int().min(1).max(4).default(3).describe("How many businesses to enrich in parallel. Keep low to respect per-account concurrency limits."),proxyMode:j.enum(["configured","none"]).default(O).describe("Proxy behavior for the Maps search. Leave unset for clean egress; country/region localization comes from gl/hl plus the city or region in the query.")}),dt=["position","business_name","review_stars","review_count","category","address","phone","website","email","email_2","email_domain_match","email_status","socials","booking_url","place_url","cid","source_location"];async function gt(e,t,n){let r=new Array(e.length),i=0;async function s(){for(;i<e.length;){let a=i;i+=1,r[a]=await n(e[a],a)}}return await Promise.all(Array.from({length:Math.min(t,e.length)},()=>s())),r}function wt(e){try{return new URL(e).hostname.toLowerCase().replace(/^www\./,"").replace(/\.$/,"")}catch{return""}}function Le(e,t){let n=wt(t),r=e.slice(e.lastIndexOf("@")+1).toLowerCase().replace(/^www\./,"").replace(/\.$/,"");return!!(n&&r===n)}function Oe(e,t){let n=new Set(e.map(r=>r.value.toLowerCase()));for(let r of t){if(e.length>=20)break;let i=r.value.toLowerCase();n.has(i)||(n.add(i),e.push(r))}}function qe(e,t,n){let r=new Set(e.map(i=>i.url));for(let i of t){if(e.length>=n)break;r.has(i.url)||(r.add(i.url),e.push(i))}}function Te(e,t){let n=[...e],r=[],i={entityType:"business",name:t,organization:t};for(;n.length;){let s=Re(n,i);if(!s){r.push(...n);break}r.push(s);let a=n.findIndex(u=>u.value.toLowerCase()===s.value.toLowerCase());n.splice(a,1)}return r}var je={id:"get-leads",title:"Get Leads",description:"Build an outreach-ready local lead list: Google Maps search for a niche in a market, confirm review counts + booking URLs, then visit each business website (home + contact) to harvest email and social links. An opt-in SERP fallback can recover exact-domain public email occurrences after bounded pages are empty. Saves a leads CSV.",inputSchema:pt,async run(e,t){await t.artifacts.writeManifest("running",{},[],[]);let n=[],r=[],i=await t.client.post("/maps/search",{query:e.query,location:e.location,maxResults:e.maxResults,proxyMode:e.proxyMode},18e4);await t.artifacts.writeJson("Maps search raw","raw/maps-search.json",i);let s=new Set,a=i.results.filter(o=>{let y=o.cid??o.placeUrl??o.name.toLowerCase();return s.has(y)?!1:(s.add(y),!0)}),u=await gt(a,e.concurrency,async o=>{let y=o.reviewCount??"",S="",p=o.websiteUrl??"";if(e.hydrateReviewCounts)try{let E=await t.client.post("/maps/place",{businessName:o.name,location:e.location,includeReviews:!1},18e4);y=E.reviewCount??y,S=E.bookingUrl??"",p=p||(E.website??"")}catch(E){n.push(`Review hydration failed for ${o.name}: ${E instanceof Error?E.message:String(E)}`)}let C="",x="",B=[],U=p?"no email found":"no website",z="",b=[],L=[],Z=[],fe=[];if(e.enrichWebsites&&p){let E=ee(p,Z,3),he=!1,oe=new Set;for(;oe.size<3;){let A=E.find(I=>!oe.has(I));if(!A)break;oe.add(A),fe.push(A);try{let I=await t.client.post("/extract-url",{url:A},12e4);he=!0;let ae=I.contactEvidence??be(I.bodyHtml??I.bodyMarkdown??"",A);if(Oe(b,ae.emails),qe(L,ae.socialProfiles,20),qe(Z,ae.candidatePageUrls,20),E=ee(p,Z,3),b.length)break}catch{E=ee(p,Z,3);continue}}if(!b.length&&e.emailSearchFallback==="serp_snippets"){let A=Se(p);if(A)try{let I=await t.client.post("/harvest/sync",{query:A,serpOnly:!0,pages:1},18e4);Oe(b,xe({websiteUrl:p,results:I.result?.organicResults??[]}))}catch(I){n.push(`Email snippet search failed for ${o.name}: ${I instanceof Error?I.message:String(I)}`)}}B=L.map(A=>A.url).slice(0,5);let ye=Te(b,o.name),ve=ye.filter(A=>Le(A.value,p)),se=ve.length?ve.slice(0,2):ye.slice(0,1);C=se[0]?.value??"",x=se[1]?.value??"",C?(z=Le(C,p)?"yes":"NO-verify",U=se.some(A=>A.sourceType==="serp_snippet")?"serp snippet \u2014 public occurrence, verify":z==="yes"?"ok":"ok (off-domain \u2014 verify)"):he?B.length&&(U="form/social only"):U="site unreachable"}return{row:{position:o.position,business_name:o.name,review_stars:o.rating??"",review_count:y,category:o.category??"",address:o.address??"",phone:o.phone??"",website:p,email:C,email_2:x,email_domain_match:z,email_status:U,socials:B.join(" ; "),booking_url:S,place_url:o.placeUrl,cid:o.cid??"",source_location:e.location},emailEvidence:Te(b,o.name),socialProfileEvidence:L,attemptedUrls:fe}}),l=u.map(o=>o.row);await t.artifacts.writeCsv("Leads CSV","exports/leads.csv",dt,l),await t.artifacts.writeJson("Leads evidence","evidence.json",{input:e,search:{query:i.searchQuery,resultCount:i.resultCount},rows:u.map(o=>({...o.row,emailEvidence:o.emailEvidence,socialProfileEvidence:o.socialProfileEvidence,attemptedUrls:o.attemptedUrls}))});let d=l.filter(o=>o.email).length,m=l.filter(o=>o.email_domain_match==="yes").length,f=l.filter(o=>o.review_count).length,_=l.filter(o=>o.socials).length,h=l.filter(o=>o.website).length,k=`${l.length} ${e.query} in ${e.location}: ${d} emails (${m} domain-matched), ${f} review counts, ${_} with socials.`;await t.artifacts.writeText("Summary","summary.md",`# Get Leads
|
|
13
|
-
|
|
14
|
-
${k}
|
|
15
|
-
`),await t.artifacts.writeText("Agent tasks","tasks.md",["# Get Leads \u2014 next steps","","- [ ] Verify deliverability of the harvested emails before outreach (MX/SMTP check).",'- [ ] For "form/social only" rows, use the website contact form or the captured social profile.','- [ ] Treat "off-domain \u2014 verify" emails with care; they may belong to a web developer or parent brand.',"- [ ] Respect CAN-SPAM / GDPR \u2014 scraped contact data is not consent to email."].join(`
|
|
16
|
-
`));let g=await t.artifacts.writeHtml("HTML report","report.html",$({title:"Get Leads",subtitle:`${e.query} \xB7 ${e.location}`,summary:k,warnings:n,tables:[{title:"Leads",columns:["position","business_name","review_stars","review_count","phone","website","email","email_2","email_status","socials","booking_url"],rows:l}]})),R=r.length?"failed":n.length?"partial":"succeeded",w={businesses:l.length,withWebsite:h,emails:d,domainMatchedEmails:m,reviewCounts:f,withSocials:_};return await t.artifacts.writeManifest(R,w,n,r),{title:"Get Leads",summary:k,status:R,counts:w,warnings:n,errors:r,reportPath:g}}};import{z as W}from"zod";var ft=W.object({query:W.string().min(1),state:W.string().min(2).default("TN"),minPopulation:W.number().int().min(0).default(1e5),maxCities:W.number().int().min(1).max(100).default(25),maxResultsPerCity:W.number().int().min(1).max(50).default(20),hydrateTop:W.number().int().min(0).max(10).default(5),maxReviews:W.number().int().min(0).max(1e3).default(50),concurrency:W.number().int().min(1).max(5).default(5),proxyMode:W.enum(["configured","none"]).default(O),returnPartial:W.boolean().default(!0)});async function ht(e,t,n){let r=new Array(e.length),i=0;async function s(){for(;i<e.length;){let a=i;i+=1,r[a]=await n(e[a],a)}}return await Promise.all(Array.from({length:Math.min(t,e.length)},()=>s())),r}function ue(e){if(e==null||e==="")return null;let t=Number(String(e).replace(/[^\d.]/g,""));return Number.isFinite(t)?t:null}function Ue(e){let t=e.filter(n=>n!==null).sort((n,r)=>n-r);return t.length?t[Math.floor(t.length/2)]??null:null}function He(e){let t=new Set(["the","and","for","with","that","this","was","were","are","you","our","they","had","have","not","but","from","very","great","good"]),n=new Map;for(let r of e)for(let i of r.toLowerCase().replace(/[^a-z0-9\s]/g," ").split(/\s+/))i.length<4||t.has(i)||n.set(i,(n.get(i)??0)+1);return[...n.entries()].sort((r,i)=>i[1]-r[1]).slice(0,8).map(([r,i])=>`${r} (${i})`).join("; ")}var Be={id:"local-competitive-audit",title:"Local Competitive Audit",description:"Audit local Maps competitors, categories, review counts, and review themes across city markets.",inputSchema:ft,async run(e,t){await t.artifacts.writeManifest("running",{},[],[]);let n=[],r=[],i=await t.client.post("/directory/run",{query:e.query,state:e.state,minPopulation:e.minPopulation,maxCities:e.maxCities,maxResultsPerCity:e.maxResultsPerCity,concurrency:e.concurrency,proxyMode:e.proxyMode,saveCsv:!0,background:!1},9e5);await t.artifacts.writeJson("Directory raw JSON","raw/directory-workflow.json",i);let s=Y(i);await t.artifacts.writeCsv("Base directory CSV","exports/directory.csv",X,s);let a=i.cities.flatMap(w=>w.results.slice(0,e.hydrateTop).map(o=>({city:w,result:o}))),u=new Set,l=a.filter(({city:w,result:o})=>{let y=o.cid??o.placeUrl??`${w.location}:${o.name.toLowerCase()}`;return u.has(y)?!1:(u.add(y),!0)}),d=await ht(l,3,async({city:w,result:o},y)=>{try{let S=await t.client.post("/maps/place",{businessName:o.name,location:w.location,includeReviews:e.maxReviews>0,maxReviews:Math.max(1,e.maxReviews)},18e4);return await t.artifacts.writeJson(`${o.name} profile`,`raw/maps-place-intel/${y+1}-${o.name.toLowerCase().replace(/[^a-z0-9]+/g,"-")}.json`,S),{city:w,result:o,detail:S,error:null}}catch(S){let p=S instanceof Error?S.message:String(S);return n.push(`Profile hydration failed for ${o.name} (${w.location}): ${p}`),{city:w,result:o,detail:null,error:p}}}),m=d.map(({city:w,result:o,detail:y,error:S})=>{let p=y?.reviews??[],C=p.filter(x=>x.ownerResponse).length;return{city:w.city,state:w.state,source_location:w.location,result_position:o.position,business_name:o.name,category:y?.category??o.category,review_stars:y?.rating??o.rating,review_count:y?.reviewCount??o.reviewCount,phone:o.phone,website_url:y?.website??o.websiteUrl,place_url:o.placeUrl,cid:o.cid,cid_decimal:o.cidDecimal,hydrated:y?"true":"false",reviews_status:y?.reviewsStatus??"",review_topics:(y?.reviewTopics??[]).map(x=>`${x.label} (${x.count})`).join("; "),owner_response_rate:p.length?(C/p.length).toFixed(2):"",error:S??""}}),f=d.map(({city:w,result:o,detail:y})=>{let S=y?.reviews??[],p=S.filter(x=>Number(x.stars)>=5&&x.text).map(x=>x.text),C=S.filter(x=>Number(x.stars)>0&&Number(x.stars)<=3&&x.text).map(x=>x.text);return{city:w.city,business_name:o.name,cid:o.cid,review_count:y?.reviewCount??o.reviewCount,average_rating:y?.rating??o.rating,topics:(y?.reviewTopics??[]).map(x=>`${x.label} (${x.count})`).join("; "),praise_terms:He(p),complaint_terms:He(C),positive_sample:p[0]?.slice(0,280)??"",negative_sample:C[0]?.slice(0,280)??""}}),_=i.cities.map(w=>{let o=w.results.map(b=>ue(b.reviewCount)),y=w.results.map(b=>ue(b.rating)),S=w.results.slice(0,3).map(b=>ue(b.reviewCount)).filter(b=>b!==null),p=new Map;for(let b of w.results)b.category&&p.set(b.category,(p.get(b.category)??0)+1);let C=Ue(o),x=Ue(y),B=S.length?Math.round(S.reduce((b,L)=>b+L,0)/S.length):null,U=Math.min(100,Math.round((B??0)/20+(x??0)*10+w.results.filter(b=>b.websiteUrl).length)),z=Math.max(0,100-U);return{city:w.city,state:w.state,population:w.population,result_count:w.resultCount,median_review_count:C??"",median_rating:x??"",top_three_average_review_count:B??"",top_categories:[...p.entries()].sort((b,L)=>L[1]-b[1]).slice(0,5).map(([b,L])=>`${b} (${L})`).join("; "),opportunity_score:z,difficulty_score:U}});await t.artifacts.writeCsv("Competitors CSV","competitors.csv",["city","state","source_location","result_position","business_name","category","review_stars","review_count","phone","website_url","place_url","cid","cid_decimal","hydrated","reviews_status","review_topics","owner_response_rate","error"],m),await t.artifacts.writeCsv("Review insights CSV","review-insights.csv",["city","business_name","cid","review_count","average_rating","topics","praise_terms","complaint_terms","positive_sample","negative_sample"],f),await t.artifacts.writeCsv("City summary CSV","city-summary.csv",["city","state","population","result_count","median_review_count","median_rating","top_three_average_review_count","top_categories","opportunity_score","difficulty_score"],_),await t.artifacts.writeJson("Audit evidence","evidence.json",{input:e,directory:i,hydrated:d,citySummaryRows:_,competitorRows:m,reviewInsightRows:f}),await t.artifacts.writeText("Agent tasks","tasks.md",["# Local Competitive Audit Tasks","","- [ ] Review city opportunity and difficulty scores as heuristics, not absolute truth.","- [ ] Use review topics and samples as customer-language evidence.","- [ ] Compare target GBP category, review count, and website quality against top competitors.","- [ ] Identify cities with low review-count leaders and weak website coverage."].join(`
|
|
17
|
-
`));let h=`${i.selectedCityCount} cities, ${i.totalResultCount} Maps results, ${d.filter(w=>w.detail).length} hydrated profiles.`;await t.artifacts.writeText("Summary","summary.md",`# Local Competitive Audit
|
|
18
|
-
|
|
19
|
-
${h}
|
|
20
|
-
`);let k=await t.artifacts.writeHtml("HTML report","report.html",$({title:"Local Competitive Audit",subtitle:`${e.query} \xB7 ${e.state}`,summary:h,warnings:n,tables:[{title:"City Opportunity",columns:["city","state","population","result_count","median_review_count","median_rating","top_three_average_review_count","top_categories","opportunity_score","difficulty_score"],rows:_},{title:"Hydrated Competitors",columns:["city","result_position","business_name","category","review_stars","review_count","hydrated","review_topics"],rows:m.slice(0,100)},{title:"Review Insights",columns:["city","business_name","topics","praise_terms","complaint_terms"],rows:f.slice(0,100)}]})),g=n.length||i.cities.some(w=>w.status==="failed")?"partial":"succeeded",R={cities:i.selectedCityCount,mapsResults:i.totalResultCount,hydratedProfiles:d.filter(w=>w.detail).length};return await t.artifacts.writeManifest(g,R,n,r),{title:"Local Competitive Audit",summary:h,status:g,counts:R,warnings:n,errors:r,reportPath:k}}};import{z as v}from"zod";var yt=new Set(["about","after","also","because","been","best","both","from","have","into","more","most","near","only","over","than","that","their","them","then","there","these","they","this","what","when","where","which","while","with","your","will","would","should","could","does","were","cost","costs"]);function M(e){if(!e)return null;try{return new URL(e.includes("://")?e:`https://${e}`).hostname.replace(/^www\./,"").toLowerCase()}catch{return e.replace(/^https?:\/\//,"").replace(/^www\./,"").split("/")[0]?.toLowerCase()||null}}function P(e){return M(e)??""}function H(e){if(e==null||e==="")return null;let t=Number(String(e).replace(/[^\d.]/g,""));return Number.isFinite(t)?t:null}function me(e){let t=e.filter(n=>n!==null).sort((n,r)=>n-r);return t.length?t[Math.floor(t.length/2)]??null:null}function pe(e,t=12){let n=new Map;for(let r of e.toLowerCase().replace(/[^a-z0-9\s]/g," ").split(/\s+/))r.length<4||yt.has(r)||n.set(r,(n.get(r)??0)+1);return[...n.entries()].sort((r,i)=>i[1]-r[1]||r[0].localeCompare(i[0])).slice(0,t).map(([r,i])=>`${r} (${i})`).join("; ")}function vt(e){let t=e.toLowerCase();return/\b(cost|price|pricing|charge|expensive|cheap)\b/.test(t)?"cost":/\b(best|top|recommended|reviews?|compare|versus|vs)\b/.test(t)?"comparison":/\b(how|steps?|process|way to)\b/.test(t)?"process":/\b(why|worth|important|benefit)\b/.test(t)?"why":/\b(near me|city|local|nearby)\b/.test(t)?"local":/\b(can|does|do|is|are|should|will)\b/.test(t)?"decision":"definition"}function re(e){return(e?.flat??[]).filter(t=>t.question).map((t,n)=>{let r=t.source_cite??"",i=M(t.source_site??"")??P(r);return{position:n+1,intent:vt(t.question??""),question:t.question??"",answer_excerpt:(t.answer??"").slice(0,320),source_title:t.source_title??"",source_domain:i,source_url:r}})}function Ne(e){let t=new Map;for(let n of e){let r=String(n.source_domain??n.domain??"");if(!r)continue;let i=t.get(r)??{questions:0,urls:new Set,intents:new Map};i.questions+=n.question?1:0,(n.source_url||n.url)&&i.urls.add(String(n.source_url??n.url)),n.intent&&i.intents.set(String(n.intent),(i.intents.get(String(n.intent))??0)+1),t.set(r,i)}return[...t.entries()].map(([n,r])=>({domain:n,question_mentions:r.questions,source_url_count:r.urls.size,top_intents:[...r.intents.entries()].sort((i,s)=>s[1]-i[1]).map(([i,s])=>`${i} (${s})`).join("; ")})).sort((n,r)=>Number(r.question_mentions)-Number(n.question_mentions)||String(n.domain).localeCompare(String(r.domain)))}function ze(e){return(e??"").replace(/\s+/g," ").split(/(?<=[.!?])\s+/).map(t=>t.trim()).filter(t=>t.length>20).slice(0,20)}function Fe(e){let t=e.toLowerCase();return/\bis\b|\bare\b|\bmeans\b|\brefers to\b/.test(t)?"definition":/\binclude\b|\bconsider\b|\bfactors?\b|\bcriteria\b/.test(t)?"criteria":/\bfirst\b|\bthen\b|\bsteps?\b|\bprocess\b/.test(t)?"process":/\bvs\b|\bthan\b|\bcompare\b|\bdifference\b/.test(t)?"comparison":/\bcost\b|\bprice\b|\baverage\b|\brange\b/.test(t)?"cost":"claim"}function ne(e,t){return{position:t.position??"",domain:t.domain,url:t.url,serp_title:t.title??"",page_title:e.title??"",h1:e.h1??"",meta_description:e.metaDescription??"",word_count:e.wordCount??"",heading_count:e.headings?.length??0,schema_types:(e.schemaTypes??[]).join("; ")}}async function de(e,t,n){let r=new Array(e.length),i=0;async function s(){for(;i<e.length;){let a=i;i+=1,r[a]=await n(e[a],a)}}return await Promise.all(Array.from({length:Math.min(Math.max(1,t),e.length)},()=>s())),r}var _t=v.enum(["configured","none"]),bt=v.object({query:v.string().min(1),location:v.string().optional(),state:v.string().optional(),minPopulation:v.number().int().min(0).default(1e5),maxCities:v.number().int().min(1).max(100).default(5),maxResultsPerCity:v.number().int().min(1).max(50).default(20),hydrateTop:v.number().int().min(0).max(10).default(5),maxReviews:v.number().int().min(0).max(1e3).default(25),concurrency:v.number().int().min(1).max(5).default(5),proxyMode:_t.default(O),returnPartial:v.boolean().default(!0)}).refine(e=>e.location||e.state,{message:"Either location or state is required for map-comparison"}),kt=v.object({keyword:v.string().min(1),domain:v.string().optional(),url:v.string().url().optional(),location:v.string().optional(),maxResults:v.number().int().min(1).max(20).default(10),maxQuestions:v.number().int().min(1).max(100).default(40),extractTop:v.number().int().min(0).max(10).default(5),includePaa:v.boolean().default(!0),includeAiOverview:v.boolean().default(!0),returnPartial:v.boolean().default(!0)}),Rt=v.object({keyword:v.string().min(1),location:v.string().optional(),maxQuestions:v.number().int().min(1).max(100).default(80),depth:v.number().int().min(1).max(6).default(3),returnPartial:v.boolean().default(!0)}),St=v.object({keyword:v.string().min(1),domain:v.string().optional(),url:v.string().url().optional(),location:v.string().optional(),maxQuestions:v.number().int().min(1).max(100).default(40),extractTop:v.number().int().min(0).max(8).default(3),returnPartial:v.boolean().default(!0)});function xt(e,t,n){return n.map(r=>({source_query:t,source_location:e,city:e.split(",")[0]?.trim()??e,state:e.split(",")[1]?.trim()??"",population:"",result_position:r.position,business_name:r.name,review_stars:r.rating??"",review_count:r.reviewCount??"",category:r.category??"",address:r.address??"",phone:r.phone??"",website_url:r.websiteUrl??"",place_url:r.placeUrl??"",cid:r.cid??"",cid_decimal:r.cidDecimal??"",result_status:"ok",error:""}))}function Je(e){let t=new Map;for(let n of e){let r=String(n.source_location??n.location??"");if(!r)continue;let i=t.get(r)??[];i.push(n),t.set(r,i)}return[...t.entries()].map(([n,r])=>{let i=r.map(l=>H(l.review_count)),s=r.map(l=>H(l.review_stars)),a=r.slice(0,3).map(l=>H(l.review_count)).filter(l=>l!==null),u=new Map;for(let l of r){let d=String(l.category??"");d&&u.set(d,(u.get(d)??0)+1)}return{source_location:n,result_count:r.filter(l=>l.business_name).length,median_review_count:me(i)??"",median_rating:me(s)??"",top_three_average_review_count:a.length?Math.round(a.reduce((l,d)=>l+d,0)/a.length):"",top_categories:[...u.entries()].sort((l,d)=>d[1]-l[1]).slice(0,5).map(([l,d])=>`${l} (${d})`).join("; "),websites_present:r.filter(l=>l.website_url).length}})}function Ct(e){let t=new Map;for(let n of Je(e))t.set(String(n.source_location),H(n.top_three_average_review_count)??0);return e.filter(n=>n.business_name).map(n=>{let r=H(n.review_count)??0,i=t.get(String(n.source_location))??0,s=!n.website_url,a=H(n.result_position)??999;return{source_location:n.source_location,result_position:n.result_position,business_name:n.business_name,category:n.category,review_stars:n.review_stars,review_count:n.review_count,review_gap_to_top3_average:i?Math.max(0,i-r):"",website_url:n.website_url,place_url:n.place_url,comparison_note:a<=3?"visible leader":s?"ranking without website":r<i?"review-light competitor":"visible competitor"}})}function At(e,t){return(e?.organicResults??[]).map(n=>{let r=n.url??"",i=M(n.domain??"")??P(r);return{position:n.position??"",title:n.title??"",url:r,domain:i,snippet:n.snippet??"",is_target:t?i===t:!1}})}function Pt(e,t){let n=new Set((e?.headings??[]).map(s=>s.text.toLowerCase().replace(/[^a-z0-9\s]/g," ").trim())),r=new Set((e?.headings??[]).flatMap(s=>s.text.toLowerCase().replace(/[^a-z0-9\s]/g," ").split(/\s+/).filter(Boolean))),i=[];for(let{source:s,page:a}of t)for(let u of a.headings??[]){if(u.level>3||!u.text)continue;let l=u.text.toLowerCase().replace(/[^a-z0-9\s]/g," ").trim(),d=l.split(/\s+/).filter(_=>_.length>3),m=d.filter(_=>r.has(_)).length;(n.has(l)||m>=Math.max(2,Math.ceil(d.length/2)))&&e||i.push({source_position:s.position??"",source_domain:M(s.domain??"")??P(s.url),source_url:s.url??"",heading_level:u.level,competitor_heading:u.text,target_coverage:e?"not found in target headings":"no target page extracted",terms:pe(u.text,6)})}return i.slice(0,150)}async function ge(e,t,n,r){return de(t.filter(i=>i.url),2,async(i,s)=>{try{let a=await e.client.post("/extract-url",{url:i.url},18e4);return await e.artifacts.writeJson(`${r} ${s+1}`,`raw/extract-url/${r.toLowerCase()}-${s+1}.json`,a),{source:i,page:a}}catch(a){return n.push(`Page extraction failed for ${i.url}: ${a instanceof Error?a.message:String(a)}`),null}}).then(i=>i.filter(s=>s!==null))}var Ve={id:"map-comparison",title:"Maps Comparison",description:"Compare Google Maps competitors by rank, reviews, stars, categories, websites, and profile/review signals.",inputSchema:bt,async run(e,t){await t.artifacts.writeManifest("running",{},[],[]);let n=[],r,i=null,s=null;e.location?(s=await t.client.post("/maps/search",{query:e.query,location:e.location,maxResults:e.maxResultsPerCity,proxyMode:e.proxyMode},24e4),r=xt(e.location,e.query,s.results),await t.artifacts.writeJson("Maps search raw JSON","raw/maps-search.json",s)):(i=await t.client.post("/directory/run",{query:e.query,state:e.state,minPopulation:e.minPopulation,maxCities:e.maxCities,maxResultsPerCity:e.maxResultsPerCity,concurrency:e.concurrency,proxyMode:e.proxyMode,saveCsv:!0,background:!1},9e5),r=Y(i),await t.artifacts.writeJson("Directory raw JSON","raw/directory-workflow.json",i),await t.artifacts.writeCsv("Directory CSV","exports/directory.csv",X,r),n.push(...i.warnings));let a=Ct(r),u=a.slice(0,e.hydrateTop*Math.max(1,e.location?1:e.maxCities)),d=(await de(u,3,async(g,R)=>{try{let w=await t.client.post("/maps/place",{businessName:g.business_name,location:g.source_location,includeReviews:e.maxReviews>0,maxReviews:Math.max(1,e.maxReviews)},18e4);return await t.artifacts.writeJson(`${g.business_name} profile`,`raw/maps-place-intel/${R+1}-${String(g.business_name).toLowerCase().replace(/[^a-z0-9]+/g,"-")}.json`,w),{row:g,detail:w,error:""}}catch(w){let o=w instanceof Error?w.message:String(w);return n.push(`Profile hydration failed for ${g.business_name}: ${o}`),{row:g,detail:null,error:o}}})).map(({row:g,detail:R,error:w})=>({source_location:g.source_location,result_position:g.result_position,business_name:g.business_name,category:R?.category??g.category,review_stars:R?.rating??g.review_stars,review_count:R?.reviewCount??g.review_count,website_url:R?.website??g.website_url,review_topics:(R?.reviewTopics??[]).map(o=>`${o.label} (${o.count})`).join("; "),about_attributes:(R?.aboutAttributes??[]).map(o=>`${o.section}: ${o.attribute}`).join("; "),reviews_status:R?.reviewsStatus??"",error:w})),m=Je(r);await t.artifacts.writeCsv("Maps results CSV","maps-results.csv",["source_query","source_location","city","state","population","result_position","business_name","review_stars","review_count","category","address","phone","website_url","place_url","cid","cid_decimal","result_status","error"],r),await t.artifacts.writeCsv("Comparison CSV","map-comparison.csv",["source_location","result_position","business_name","category","review_stars","review_count","review_gap_to_top3_average","website_url","place_url","comparison_note"],a),await t.artifacts.writeCsv("Profile insights CSV","profile-insights.csv",["source_location","result_position","business_name","category","review_stars","review_count","website_url","review_topics","about_attributes","reviews_status","error"],d),await t.artifacts.writeJson("Maps comparison evidence","evidence.json",{input:e,directory:i,mapsSearch:s,rows:r,compareRows:a,profileRows:d,markets:m,warnings:n}),await t.artifacts.writeText("Brief","brief.md",[`# Maps Comparison: ${e.query}`,"",`Markets: ${m.map(g=>g.source_location).join(", ")}`,"","## How to Use","- Compare rank position against review count and category patterns.","- Treat review gaps and missing websites as opportunity signals, not guarantees.","- Use profile topics and attributes as evidence for local content and GBP improvements."].join(`
|
|
21
|
-
`));let f=`${a.length} Maps competitors compared across ${m.length} market(s); ${d.filter(g=>!g.error).length} profiles hydrated.`,_=await t.artifacts.writeHtml("HTML report","report.html",$({title:"Maps Comparison",subtitle:`${e.query}${e.location?` \xB7 ${e.location}`:e.state?` \xB7 ${e.state}`:""}`,summary:f,warnings:n,tables:[{title:"Market Benchmarks",columns:["source_location","result_count","median_review_count","median_rating","top_three_average_review_count","top_categories","websites_present"],rows:m},{title:"Competitor Comparison",columns:["source_location","result_position","business_name","category","review_stars","review_count","review_gap_to_top3_average","comparison_note"],rows:a.slice(0,120)},{title:"Profile Insights",columns:["source_location","business_name","review_topics","about_attributes","error"],rows:d}]})),h=n.length?"partial":"succeeded",k={markets:m.length,competitors:a.length,hydratedProfiles:d.filter(g=>!g.error).length};return await t.artifacts.writeManifest(h,k,n,[]),{title:"Maps Comparison",summary:f,status:h,counts:k,warnings:n,errors:[],reportPath:_}}},Ge={id:"serp-comparison",title:"SERP Comparison",description:"Compare ranking pages, SERP features, PAA evidence, AI Overview citations, and page-level content gaps.",inputSchema:kt,async run(e,t){await t.artifacts.writeManifest("running",{},[],[]);let n=[],r=M(e.domain??e.url??null),i=await t.client.post("/harvest/sync",{query:e.keyword,location:e.location,serpOnly:!0,includeAllSerpFeatures:!0,maxQuestions:1,format:"json"},62e4);await t.artifacts.writeJson("SERP raw JSON","raw/serp.json",i);let s=null;if(e.includePaa)try{s=await t.client.post("/harvest/sync",{query:e.keyword,location:e.location,maxQuestions:e.maxQuestions,includeAllSerpFeatures:!0,format:"json"},735e3),await t.artifacts.writeJson("PAA raw JSON","raw/paa.json",s)}catch(p){n.push(`PAA evidence unavailable: ${p instanceof Error?p.message:String(p)}`)}let a=At(i,r).slice(0,e.maxResults),u=(i.organicResults??[]).slice(0,e.maxResults),l=e.url?{position:0,title:"Target page",url:e.url,domain:P(e.url)}:u.find(p=>r&&(M(p.domain??"")??P(p.url))===r),d=u.filter(p=>p.url&&p.url!==l?.url).filter(p=>!r||(M(p.domain??"")??P(p.url))!==r).slice(0,e.extractTop),m=l?await ge(t,[l],n,"Target"):[],f=e.extractTop>0?await ge(t,d,n,"Competitor"):[],_=m[0]?.page??null,h=[...m.map(({source:p,page:C})=>ne(C,{url:p.url??"",domain:M(p.domain??"")??P(p.url),position:p.position,title:p.title})),...f.map(({source:p,page:C})=>ne(C,{url:p.url??"",domain:M(p.domain??"")??P(p.url),position:p.position,title:p.title}))],k=Pt(_,f),g=re(s),R=(i.aiOverview?.citations??[]).map((p,C)=>({citation_position:C+1,citation_text:p.text??"",url:p.href??"",domain:P(p.href??""),is_target:r?P(p.href??"")===r:!1}));await t.artifacts.writeCsv("Organic results CSV","organic-results.csv",["position","title","url","domain","snippet","is_target"],a),await t.artifacts.writeCsv("Page comparison CSV","page-comparison.csv",["position","domain","url","serp_title","page_title","h1","meta_description","word_count","heading_count","schema_types"],h),await t.artifacts.writeCsv("Content gaps CSV","content-gaps.csv",["source_position","source_domain","source_url","heading_level","competitor_heading","target_coverage","terms"],k),await t.artifacts.writeCsv("PAA questions CSV","paa-questions.csv",["position","intent","question","answer_excerpt","source_title","source_domain","source_url"],g),await t.artifacts.writeCsv("AI Overview citations CSV","ai-overview-citations.csv",["citation_position","citation_text","url","domain","is_target"],R),await t.artifacts.writeJson("SERP comparison evidence","evidence.json",{input:e,serp:i,paa:s,organic:a,pageRows:h,gaps:k,questions:g,aiRows:R,warnings:n}),await t.artifacts.writeText("Writer brief","brief.md",[`# SERP Comparison Brief: ${e.keyword}`,"",`Target: ${r??e.url??"not specified"}`,`Location: ${e.location??"not specified"}`,"","## Recommended Actions","- Use `content-gaps.csv` to decide which missing sections deserve coverage.","- Use `paa-questions.csv` for FAQ and answer-block candidates.","- Use `ai-overview-citations.csv` to see whether the target is cited in AI Overview evidence.","- Treat extracted page headings as evidence, not a complete semantic analysis."].join(`
|
|
22
|
-
`));let w=`${a.length} organic results, ${h.length} extracted pages, ${k.length} heading gaps, ${g.length} PAA questions.`,o=await t.artifacts.writeHtml("HTML report","report.html",$({title:"SERP Comparison",subtitle:`${e.keyword}${e.location?` \xB7 ${e.location}`:""}`,summary:w,warnings:n,tables:[{title:"Organic Results",columns:["position","title","domain","is_target"],rows:a},{title:"Page Comparison",columns:["position","domain","h1","word_count","heading_count","schema_types"],rows:h},{title:"Content Gaps",columns:["source_position","source_domain","competitor_heading","target_coverage","terms"],rows:k.slice(0,80)},{title:"PAA Questions",columns:["position","intent","question","source_domain"],rows:g.slice(0,80)}]})),y=n.length?"partial":"succeeded",S={organic:a.length,pages:h.length,gaps:k.length,questions:g.length,aiCitations:R.length};return await t.artifacts.writeManifest(y,S,n,[]),{title:"SERP Comparison",summary:w,status:y,counts:S,warnings:n,errors:[],reportPath:o}}},Qe={id:"paa-expansion-brief",title:"PAA Expansion Brief",description:"Expand People Also Ask questions into an evidence-backed writer brief, section map, and source table.",inputSchema:Rt,async run(e,t){await t.artifacts.writeManifest("running",{},[],[]);let n=[],r=await t.client.post("/harvest/sync",{query:e.keyword,location:e.location,maxQuestions:e.maxQuestions,depth:e.depth,format:"json"},735e3);await t.artifacts.writeJson("PAA raw JSON","raw/paa.json",r);let i=re(r),s=Ne(i),a=new Map;for(let f of i){let _=a.get(String(f.intent))??[];_.push(f),a.set(String(f.intent),_)}let u=[...a.entries()].map(([f,_])=>({recommended_section:f,question_count:_.length,sample_questions:_.slice(0,5).map(h=>h.question).join(" | "),source_domains:[...new Set(_.map(h=>h.source_domain).filter(Boolean))].slice(0,5).join("; "),terms:pe(_.map(h=>`${h.question} ${h.answer_excerpt}`).join(" "),10)})).sort((f,_)=>Number(_.question_count)-Number(f.question_count));await t.artifacts.writeCsv("PAA questions CSV","paa-questions.csv",["position","intent","question","answer_excerpt","source_title","source_domain","source_url"],i),await t.artifacts.writeCsv("Source domains CSV","source-domains.csv",["domain","question_mentions","source_url_count","top_intents"],s),await t.artifacts.writeCsv("Section map CSV","section-map.csv",["recommended_section","question_count","sample_questions","source_domains","terms"],u),await t.artifacts.writeJson("PAA brief evidence","evidence.json",{input:e,paa:r,questions:i,sourceRows:s,sectionRows:u}),await t.artifacts.writeText("Writer brief","writer-brief.md",[`# PAA Expansion Brief: ${e.keyword}`,"",`Location: ${e.location??"not specified"}`,"","## Suggested Page Structure",...u.map(f=>`- ${f.recommended_section}: answer ${f.question_count} related question(s). Sample: ${f.sample_questions}`),"","## Writing Rules","- Answer the highest-frequency question in the first 60 words of each section.","- Use exact customer question language from `paa-questions.csv` for H2/H3 candidates.","- Use `source-domains.csv` to identify which source types Google is already rewarding.","- Do not invent citations; cite only rows that have a source URL."].join(`
|
|
23
|
-
`));let l=`${i.length} PAA questions grouped into ${u.length} writing sections.`,d=await t.artifacts.writeHtml("HTML report","report.html",$({title:"PAA Expansion Brief",subtitle:`${e.keyword}${e.location?` \xB7 ${e.location}`:""}`,summary:l,warnings:n,tables:[{title:"Section Map",columns:["recommended_section","question_count","sample_questions","source_domains","terms"],rows:u},{title:"Questions",columns:["position","intent","question","source_domain"],rows:i.slice(0,120)},{title:"Source Domains",columns:["domain","question_mentions","source_url_count","top_intents"],rows:s}]})),m={questions:i.length,sections:u.length,sourceDomains:s.length};return await t.artifacts.writeManifest("succeeded",m,n,[]),{title:"PAA Expansion Brief",summary:l,status:"succeeded",counts:m,warnings:n,errors:[],reportPath:d}}},Ke={id:"ai-overview-language",title:"AI Overview Language Brief",description:"Turn AI Overview, citation, PAA, and ranking-page evidence into answer-block and citation-hook guidance.",inputSchema:St,async run(e,t){await t.artifacts.writeManifest("running",{},[],[]);let n=[],r=M(e.domain??e.url??null),i=await t.client.post("/harvest/sync",{query:e.keyword,location:e.location,serpOnly:!0,includeAiOverview:!0,maxQuestions:1,format:"json"},62e4);await t.artifacts.writeJson("SERP raw JSON","raw/serp.json",i);let s=null;try{s=await t.client.post("/harvest/sync",{query:e.keyword,location:e.location,maxQuestions:e.maxQuestions,includeAiOverview:!0,format:"json"},735e3),await t.artifacts.writeJson("PAA raw JSON","raw/paa.json",s)}catch(o){n.push(`PAA evidence unavailable: ${o instanceof Error?o.message:String(o)}`)}let a=(i.aiOverview?.citations??[]).map((o,y)=>{let S=P(o.href??"");return{citation_position:y+1,citation_text:o.text??"",url:o.href??"",domain:S,is_target:r?S===r:!1}}),l=ze(i.aiOverview?.text).map((o,y)=>({position:y+1,claim_type:Fe(o),sentence:o,reusable_pattern:o.length>140?`${o.slice(0,140)}...`:o})),d=re(s),m=(i.aiOverview?.citations??[]).filter(o=>o.href).map((o,y)=>({position:y+1,title:o.text,url:o.href,domain:P(o.href)})).slice(0,e.extractTop),_=(e.extractTop>0?await ge(t,m,n,"Citation"):[]).map(({source:o,page:y})=>ne(y,{url:o.url??"",domain:M(o.domain??"")??P(o.url),position:o.position,title:o.title})),h=[{block:"direct_answer",guidance:"Open with a 40-70 word answer that directly resolves the query before adding context.",evidence_basis:d[0]?.question??e.keyword},{block:"criteria_or_steps",guidance:"List the criteria, steps, or decision factors Google is already compressing into AI Overview language.",evidence_basis:l.filter(o=>["criteria","process"].includes(String(o.claim_type))).map(o=>o.sentence).slice(0,3).join(" | ")},{block:"citation_hook",guidance:"Add source-worthy details competitors can cite: definitions, numbers, examples, process details, and named entity relationships.",evidence_basis:a.map(o=>`${o.domain}: ${o.citation_text}`).slice(0,5).join(" | ")},{block:"faq_followups",guidance:"Use PAA phrasing for follow-up sections so the page answers adjacent questions in Google language.",evidence_basis:d.slice(0,5).map(o=>o.question).join(" | ")}];await t.artifacts.writeCsv("AI Overview citations CSV","ai-overview-citations.csv",["citation_position","citation_text","url","domain","is_target"],a),await t.artifacts.writeCsv("AI Overview claim patterns CSV","claim-patterns.csv",["position","claim_type","sentence","reusable_pattern"],l),await t.artifacts.writeCsv("Language guidance CSV","language-guidance.csv",["block","guidance","evidence_basis"],h),await t.artifacts.writeCsv("PAA questions CSV","paa-questions.csv",["position","intent","question","answer_excerpt","source_title","source_domain","source_url"],d),await t.artifacts.writeCsv("Extracted citation pages CSV","citation-pages.csv",["position","domain","url","serp_title","page_title","h1","meta_description","word_count","heading_count","schema_types"],_),await t.artifacts.writeJson("AI Overview language evidence","evidence.json",{input:e,serp:i,paa:s,citations:a,claimRows:l,languageRows:h,extractedRows:_,warnings:n}),await t.artifacts.writeText("Answer block template","answer-block-template.md",[`# AI Overview Language Brief: ${e.keyword}`,"",`AI Overview detected: ${i.aiOverview?.detected?"yes":"no"}`,`Target cited: ${r?a.some(o=>o.is_target)?"yes":"no":"target not specified"}`,"","## Direct Answer Block","Write one compact answer block that starts with the answer, not background. Keep it clear enough that Google could lift it as a standalone summary.","","## Suggested Follow-Up Blocks",...h.map(o=>`- ${o.block}: ${o.guidance}`),"","## Evidence to Mirror",...l.slice(0,8).map(o=>`- ${o.claim_type}: ${o.sentence}`),"","## Citation Hooks",...a.slice(0,8).map(o=>`- ${o.domain}: ${o.citation_text}`)].join(`
|
|
24
|
-
`));let k=`${a.length} AI Overview citations, ${l.length} claim patterns, ${d.length} PAA questions, ${_.length} citation pages extracted.`,g=await t.artifacts.writeHtml("HTML report","report.html",$({title:"AI Overview Language Brief",subtitle:`${e.keyword}${e.location?` \xB7 ${e.location}`:""}`,summary:k,warnings:n,tables:[{title:"Language Guidance",columns:["block","guidance","evidence_basis"],rows:h},{title:"AI Overview Citations",columns:["citation_position","citation_text","domain","is_target"],rows:a},{title:"Claim Patterns",columns:["position","claim_type","sentence"],rows:l},{title:"PAA Follow-Ups",columns:["position","intent","question","source_domain"],rows:d.slice(0,60)}]})),R=n.length||!i.aiOverview?.detected?"partial":"succeeded",w={citations:a.length,claimPatterns:l.length,questions:d.length,extractedCitationPages:_.length};return await t.artifacts.writeManifest(R,w,n,[]),{title:"AI Overview Language Brief",summary:k,status:R,counts:w,warnings:n,errors:[],reportPath:g}}};var we=[De,je,We,Be,Ve,Ge,Qe,Ke];function jr(){return we.map(({id:e,title:t,description:n})=>({id:e,title:t,description:n}))}function ie(e){let t=we.find(n=>n.id===e);if(!t)throw new Error(`Unknown workflow "${e}". Available: ${we.map(n=>n.id).join(", ")}`);return t}function Ur(e){return ie(e).steps?.length??1}function Hr(e){let t=ie(e);return!!(t.steps&&t.steps.length>0)}function Ye(e){let t=e.apiKey?.trim()||process.env.MCP_SCRAPER_API_KEY?.trim();if(!t)throw new Error("MCP_SCRAPER_API_KEY is required for workflow runs. Pass --api-key or set the environment variable.");return t}function Xe(e){return e.apiUrl?.trim()||process.env.MCP_SCRAPER_API_URL?.trim()||"https://mcpscraper.dev"}async function Br(e,t,n={}){let r=ie(e),i=r.inputSchema.parse(t),s=Ye(n),a=Xe(n),u=await G.create(r.id,r.title,i,n.outputDir,n.runId),l=new Q(a,s,n.fetchImpl,n.headers),d={runId:u.runId,startedAt:u.startedAt,client:l,artifacts:u,signal:n.signal};try{if(r.steps&&r.steps.length>0){let m=r.createState?r.createState(i):{},f=null;for(let _ of r.steps){let h=await _.run({input:i,state:m,ctx:d});m=h.state,h.summary&&(f=h.summary)}if(!f)throw new Error(`Workflow "${e}" produced no terminal step summary`);return f}if(r.run)return await r.run(i,d);throw new Error(`Workflow "${e}" has neither steps nor a run() implementation`)}catch(m){let f=m instanceof Error?m.message:String(m);throw await u.writeText("Failure","summary.md",`# ${r.title}
|
|
25
|
-
|
|
26
|
-
${f}
|
|
27
|
-
`),await u.writeManifest("failed",{},[],[f]),m}}async function Nr(e,t,n){let r=ie(e),i=r.steps;if(!i||i.length===0)throw new Error(`Workflow "${e}" does not support stepwise execution`);if(n.stepIndex<0||n.stepIndex>=i.length)throw new Error(`Step index ${n.stepIndex} is out of range for "${e}" (${i.length} steps)`);let s=n.options??{},a=r.inputSchema.parse(t),u=Ye(s),l=Xe(s),d=await G.create(r.id,r.title,a,s.outputDir,s.runId),m=new Q(l,u,s.fetchImpl,s.headers),f={runId:d.runId,startedAt:d.startedAt,client:m,artifacts:d,signal:s.signal},_=n.state??(r.createState?r.createState(a):{}),h=i[n.stepIndex],k=await h.run({input:a,state:_,ctx:f}),g=await Promise.all(d.artifacts.map(async R=>({...R,content:await $t(R.path,"utf8").catch(()=>"")})));return{runId:d.runId,workflowId:r.id,title:r.title,stepIndex:n.stepIndex,stepId:h.id,stepTitle:h.title,totalSteps:i.length,isLast:n.stepIndex===i.length-1,output:k.output,state:k.state,warnings:k.warnings??[],summary:k.summary??null,artifacts:g}}export{Ae as a,Et as b,It as c,O as d,Ot as e,qt as f,Tt as g,jt as h,Ut as i,Bt as j,Ee as k,Ie as l,st as m,jr as n,ie as o,Ur as p,Hr as q,Br as r,Nr as s};
|