mcp-scraper 0.97.1 → 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 -2442
- 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-5X5CQAKO.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-GS657HXG.js +0 -1
- package/dist/chunk-24YDQ3EO.js +0 -5
- package/dist/chunk-2L7CHN5N.js +0 -4
- package/dist/chunk-3F7AFM53.js +0 -1
- package/dist/chunk-4AEW53RU.js +0 -954
- package/dist/chunk-4HZXATHB.js +0 -27
- package/dist/chunk-4YZ74SJ6.js +0 -1
- package/dist/chunk-4ZVO6GX4.js +0 -1
- package/dist/chunk-55ZANTHL.js +0 -3
- package/dist/chunk-5RQWFYXY.js +0 -930
- package/dist/chunk-5TQINRZN.js +0 -12
- package/dist/chunk-5UQAL7HV.js +0 -41
- package/dist/chunk-6D25Q5BR.js +0 -21728
- package/dist/chunk-6N5EC7ZO.js +0 -1
- package/dist/chunk-7POHNTVW.js +0 -1
- package/dist/chunk-7SR7MEU5.js +0 -62
- 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-C3JWX6KM.js +0 -10
- package/dist/chunk-C7MGJUTU.js +0 -1
- package/dist/chunk-CNSVZTTT.js +0 -13
- package/dist/chunk-EYGA6LOU.js +0 -1
- package/dist/chunk-F3M7INSN.js +0 -41
- package/dist/chunk-FLAWC5PF.js +0 -5
- package/dist/chunk-FM7BX2LU.js +0 -159
- package/dist/chunk-HCK6PLM3.js +0 -3
- package/dist/chunk-HNNYXMSI.js +0 -1
- package/dist/chunk-IFPION5D.js +0 -121
- package/dist/chunk-IPQOBOFY.js +0 -1
- package/dist/chunk-J7XDXIB6.js +0 -163
- package/dist/chunk-JHDD6R3O.js +0 -8
- package/dist/chunk-JMZIDHYQ.js +0 -2
- package/dist/chunk-K3VDGJNK.js +0 -1
- package/dist/chunk-KBZY2OGP.js +0 -11
- package/dist/chunk-KJQXUZ4Y.js +0 -4
- package/dist/chunk-KXJCGV3H.js +0 -1
- package/dist/chunk-NALXKTUU.js +0 -1
- package/dist/chunk-NNOX3FYG.js +0 -198
- package/dist/chunk-NQFTETVC.js +0 -189
- package/dist/chunk-OILOHQNL.js +0 -2
- package/dist/chunk-OLYPLX5C.js +0 -1
- package/dist/chunk-P6CDR3RM.js +0 -1
- package/dist/chunk-PKQHHCO4.js +0 -20
- package/dist/chunk-QCBCOEH5.js +0 -1
- 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-SJNSTO3C.js +0 -42
- package/dist/chunk-TZYITYL4.js +0 -2
- package/dist/chunk-UIOSADPB.js +0 -1718
- package/dist/chunk-UNEJYZ4T.js +0 -102
- package/dist/chunk-UUJYICAJ.js +0 -1
- package/dist/chunk-VVSHZV5S.js +0 -73
- package/dist/chunk-WNUXMPVX.js +0 -1
- package/dist/chunk-XNTAHMPA.js +0 -218
- package/dist/chunk-ZDECILF6.js +0 -16
- package/dist/chunk-ZNPGM3XE.js +0 -4
- package/dist/compatibility-UPPKZ4KY.js +0 -1
- package/dist/contracts-GUXGFCVV.js +0 -1
- package/dist/core-schema-Y47YFKH2.js +0 -899
- package/dist/direct-completion-ZVPPEBDU.js +0 -1
- package/dist/dispatch-GRMMPKQD.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/jobs-NRZHGQ7I.js +0 -1
- 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-2VKW7SGH.js +0 -1
- package/dist/reconciliation-QC6SILLR.js +0 -1
- package/dist/report-artifact-offload-PQNFDNPL.js +0 -1
- package/dist/repository-CYXVMYAI.js +0 -1
- package/dist/repository-UKDA4IWP.js +0 -1
- package/dist/server-EYMJROPX.js +0 -5544
- package/dist/settlement-47EUTSGX.js +0 -1
- package/dist/vendor-errors-647LSH6H.js +0 -1
- package/dist/worker-AWJF7UYR.js +0 -1
- package/public/.well-known/xray-install.json +0 -183
- package/public/agent-install.md +0 -200
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};
|
package/dist/chunk-4YZ74SJ6.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as E}from"./chunk-EYGA6LOU.js";var r={serp:6e3,serp_headless:6e3,serp_headful:6e3,paa:1e3,paa_base:4e4,page_scrape:100,url_map:500,yt_channel:200,yt_transcription:200,fb_ad:700,maps_search:500,maps_place:6e3,maps_review:100,fb_search:800,fb_search_result:100,fb_page_intel:700,fb_page_intel_ad:50,fb_reels_inventory:400,fb_transcribe:33300,tiktok_transcribe:33300,google_ads_search:600,google_ads_intel:200,google_ads_transcribe:33300,instagram_profile:400,instagram_media:400,instagram_transcribe:33300,browser_minute:12e3,reddit_thread:3e3,reddit_comment:200,video_analysis:666700,trustpilot_reviews:500,trustpilot_review:100,g2_reviews:500,g2_review:200,diff_page:100,listing_create:1e3,listing_edit:200},B={TOPUP:"topup",SUBSCRIPTION:"subscription",SIGNUP_GRANT:"signup_grant",MONTHLY_REFRESH:"monthly_free_refresh",PAA:"paa",PAA_REFUND:"paa_refund",SERP:"serp",SERP_REFUND:"serp_refund",REFUND:"refund",TRANSCRIPTION:"transcription",TRANSCRIPTION_HOLD:"transcription_hold",TRANSCRIPTION_REFUND:"transcription_refund",YT_CHANNEL:"yt_channel",FB_AD:"fb_ad",MAPS_SEARCH:"maps_search",DIRECTORY_WORKFLOW_HOLD:"directory_workflow_hold",DIRECTORY_WORKFLOW_REFUND:"directory_workflow_refund",LEAD_LIST_ENRICHMENT_HOLD:"lead_list_enrichment_hold",LEAD_LIST_ENRICHMENT_REFUND:"lead_list_enrichment_refund",MAPS_PLACE:"maps_place",MAPS_REVIEW:"maps_review",MAPS_REVIEW_REFUND:"maps_review_refund",EXTRACT_SITE:"extract_site",EXTRACT_SITE_REFUND:"extract_site_refund",EXTRACT_URL:"page_scrape",URL_MAP:"url_map",EXTRACT_SITE_HOLD:"extract_site_hold",YT_CHANNEL_REFUND:"yt_channel_refund",FB_AD_REFUND:"fb_ad_refund",URL_MAP_REFUND:"url_map_refund",FB_SEARCH:"fb_search",FB_REELS_INVENTORY:"fb_reels_inventory",FB_REELS_INVENTORY_REFUND:"fb_reels_inventory_refund",FB_TRANSCRIBE:"fb_transcribe",TIKTOK_TRANSCRIBE:"tiktok_transcribe",FB_SEARCH_REFUND:"fb_search_refund",FB_SEARCH_RESULT:"fb_search_result",FB_SEARCH_RESULT_REFUND:"fb_search_result_refund",FB_PAGE_INTEL:"fb_page_intel",FB_PAGE_INTEL_REFUND:"fb_page_intel_refund",FB_PAGE_INTEL_AD:"fb_page_intel_ad",FB_PAGE_INTEL_AD_REFUND:"fb_page_intel_ad_refund",FB_TRANSCRIBE_REFUND:"fb_transcribe_refund",TIKTOK_TRANSCRIBE_REFUND:"tiktok_transcribe_refund",GOOGLE_ADS_SEARCH:"google_ads_search",GOOGLE_ADS_SEARCH_REFUND:"google_ads_search_refund",GOOGLE_ADS_INTEL:"google_ads_intel",GOOGLE_ADS_INTEL_REFUND:"google_ads_intel_refund",GOOGLE_ADS_TRANSCRIBE:"google_ads_transcribe",GOOGLE_ADS_TRANSCRIBE_REFUND:"google_ads_transcribe_refund",INSTAGRAM_PROFILE:"instagram_profile",INSTAGRAM_PROFILE_REFUND:"instagram_profile_refund",INSTAGRAM_MEDIA:"instagram_media",INSTAGRAM_MEDIA_REFUND:"instagram_media_refund",INSTAGRAM_TRANSCRIBE:"instagram_transcribe",INSTAGRAM_TRANSCRIBE_REFUND:"instagram_transcribe_refund",BROWSER_SESSION:"browser_session",REDDIT_THREAD:"reddit_thread",REDDIT_THREAD_REFUND:"reddit_thread_refund",REDDIT_COMMENT:"reddit_comment",REDDIT_COMMENT_REFUND:"reddit_comment_refund",VIDEO_ANALYSIS:"video_analysis",VIDEO_ANALYSIS_REFUND:"video_analysis_refund",VIDEO_ANALYSIS_ADJUST:"video_analysis_adjust",VIDEO_ANALYSIS_LLM:"video_analysis_llm",MEMORY_AI:"memory_ai",MEMORY_AI_REFUND:"memory_ai_refund",TRUSTPILOT_REVIEWS:"trustpilot_reviews",TRUSTPILOT_REVIEWS_REFUND:"trustpilot_reviews_refund",TRUSTPILOT_REVIEW:"trustpilot_review",TRUSTPILOT_REVIEW_REFUND:"trustpilot_review_refund",G2_REVIEWS:"g2_reviews",G2_REVIEWS_REFUND:"g2_reviews_refund",G2_REVIEW:"g2_review",G2_REVIEW_REFUND:"g2_review_refund",DIFF_PAGE:"diff_page",DIFF_PAGE_REFUND:"diff_page_refund",LOCAL_SOURCEBOOK_CREATE:"local_sourcebook_create",LOCAL_SOURCEBOOK_CREATE_REFUND:"local_sourcebook_create_refund",LOCAL_SOURCEBOOK_EDIT:"local_sourcebook_edit",LOCAL_SOURCEBOOK_EDIT_REFUND:"local_sourcebook_edit_refund",COMMONS_CREATE:"commons_create",COMMONS_CREATE_REFUND:"commons_create_refund",COMMONS_EDIT:"commons_edit",COMMONS_EDIT_REFUND:"commons_edit_refund",SITE_AUDIT_LLM:"site_audit_llm",SCHEDULED_RUN:"scheduled_run",CONNECTED_USAGE:"connected_usage",CONNECTED_ACCOUNT_FEE:"connected_account_fee",ADMIN_GRANT:"admin_grant",ADMIN_REVOKE:"admin_revoke"};function Y(e){return e===!0?r.serp_headless:r.serp_headful}var a=100,l=20,_=35;function q(e,t){return e*a*(t==="apify"?l:_)}var V=r.browser_minute/6e4;function ae(e){return Math.round(e*V)}var oe=1e3,ce=l,H=r.serp_headful/a,_e=r.paa_base/a,le=r.paa/a,de=r.page_scrape/a,K={billingMode:"credits",chargeEvent:"accepted_write",validationCredits:0,create:{credits:r.listing_create/a,mc:r.listing_create},edit:{credits:r.listing_edit/a,mc:r.listing_edit},surfaces:["local_sourcebook","transparent_commons"],sourcebookAcquisitionIncluded:!0},$="2026-08-03.connected-usage-v3",y=15e3,pe=y*a,A=2,h=2,N=5,I=A*a,v=h*a,O=N*a,ue={schemaVersion:2,ratePolicyVersion:$,effectiveAt:"2026-08-03T00:00:00.000Z",provider:"nango",entitlement:"paid_plan_add_on",connection:{billingMode:"flat_recurring_credits",amountCredits:y,interval:"month",unit:"active_connection",proration:"none"},usage:{billingMode:"credits",settlementMode:"authoritative_receipt",rounding:"aggregate_then_ceil_to_mc",functionRun:{credits:A,mc:I,unit:"per_function_run"},proxyRequest:{credits:h,mc:v,unit:"per_proxy_request"},compute:{creditsPerSecond:N,mcPerSecond:O,sourceUnit:"millisecond",unit:"per_compute_second",formula:"ceil(computeMilliseconds * mcPerSecond / 1000)"}}};function g(e,t){if(!Number.isSafeInteger(e)||e<0)throw new Error(`${t} must be a non-negative safe integer`);return BigInt(e)}function p(e){if(e>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("connected usage charge exceeds the safe integer range");return Number(e)}function me(e){let t=g(e.functionRuns,"functionRuns"),o=g(e.proxyRequests,"proxyRequests"),n=g(e.computeMilliseconds,"computeMilliseconds"),s=t*BigInt(I),c=o*BigInt(v),d=n*BigInt(O),m=d===0n?0n:(d+999n)/1000n,T=s+c+m;return{functionRunMc:p(s),proxyRequestMc:p(c),computeMc:p(m),amountMc:p(T),credits:p(T)/a}}var W=[{key:"serp",label:"SERP search",aliases:["search_serp","serp","google search","organic results"],credits:l,unit:"per page (ordinary search)",notes:`search_serp light mode returns one page of organic positions, URLs, titles, and descriptions by default. Unfiltered one-page full mode returns available same-page SERP features. Either mode requests two pages only when pages:2 is explicit. Unfiltered light searches cost ${l} credits per delivered page, or ${_} credits per delivered page if the backup supplies the result. One-page full searches cost ${_} credits. Setting recency to week or month applies Google's date filter through a managed browser and returns organic results only. It costs ${_} credits for one page; filtered pages:2 follows Google's page-two control and costs ${_*2} credits when both pages are delivered. Unfiltered searches use the managed browser only as the last backup. Unfiltered two-page full searches return organic results only for ${l*2} credits, with rich features marked unsupported. If only page 1 is delivered, the search is marked partial and billed for one delivered page. A temporary ${_}-credit-per-requested-page hold is settled to the delivered rate. Location, language, device, and optional module fields do not change ordinary searches. Saved browser identity and capture_serp_snapshot searches retain their ${H}-credit base price; optional page snapshots add ${i(r.page_scrape)} credit per attempted URL.`},{key:"paa",label:"PAA harvest",aliases:["harvest_paa","paa","people also ask","questions"],credits:i(r.paa),unit:`per question (+${i(r.paa_base)} credit base)`,notes:`Returns original-query PAA questions with answers and sources plus organic results and Google entity IDs. Optional same-page SERP modules are flag-controlled. Billed ${i(r.paa_base)} credit base + ${i(r.paa)} per question actually returned (unused estimate refunded).`},{key:"page_scrape",label:"Page crawl / extract",aliases:["extract_url","extract_site","page scrape","url scrape","single page","site crawl"],credits:i(r.page_scrape),unit:"per page",notes:"Applies to both single-URL extraction and per-page site crawls."},{key:"listing_create",label:"Directory or wiki listing creation",aliases:["local-sourcebook-capture","commons_submit_entity","directory listing","wiki listing"],credits:i(r.listing_create),unit:"per new listing",notes:"Fixed total price for a new Local Sourcebook directory listing or Transparent Commons wiki entity. Sourcebook acquisition is included."},{key:"listing_edit",label:"Directory or wiki listing edit",aliases:["local_sourcebook_refresh","commons_submit_entity","listing refresh","wiki edit"],credits:i(r.listing_edit),unit:"per existing listing revision",notes:"Fixed total price for refreshing an existing Local Sourcebook listing or revising an existing Transparent Commons entity."},{key:"url_map",label:"Site URL mapping",aliases:["map_site_urls","url map","site map","crawl urls"],credits:i(r.url_map),unit:"per mapping operation",notes:"Flat rate for the full /map-urls call regardless of URL count discovered."},{key:"yt_channel",label:"YouTube search / channel harvest",aliases:["youtube_harvest","youtube search","youtube channel","yt_channel"],credits:i(r.yt_channel),unit:"per call"},{key:"yt_transcription",label:"YouTube transcription",aliases:["youtube_transcribe","youtube transcript","transcription","yt_transcription"],credits:i(2e4),unit:"base + 2/min of video",notes:"Flat 200-credit base plus 2 credits per minute of video, reconciled to the real video length after transcription (e.g. a 10-minute video is about 220 credits)."},{key:"fb_ad",label:"Facebook search / ad lookup",aliases:["facebook_page_intel","facebook_ad_search","facebook_ad","facebook ads","fb ads"],credits:i(r.fb_ad),unit:"per call"},{key:"maps_search",label:"Maps business search",aliases:["maps_search","google maps search","gmb search","gbp search","business profiles"],credits:i(r.maps_search),unit:"per search",notes:"Returns up to 50 Google Maps business/profile candidates. Use maps_place_intel to hydrate selected businesses."},{key:"maps_place",label:"Maps business lookup",aliases:["maps_place_intel","google maps","maps place","place intel"],credits:i(r.maps_place),unit:"per business",notes:"Maps place runs reserve the 60-credit base plus the declared review maximum before browsing. Completed runs settle to the base plus unique saved reviews; stopped attempts are refunded."},{key:"maps_review",label:"Maps review",aliases:["maps_reviews","google reviews","review cards","reviews"],credits:i(r.maps_review),unit:"per review card",notes:"One credit per unique saved review on a completed Maps place run. The declared maximum is held before browsing; unused credits are refunded."},{key:"fb_search",label:"Facebook ad library search",aliases:["facebook_search","fb_search","fb ad search"],credits:i(r.fb_search),unit:"per search",notes:"Browser automation to search Facebook Ads Library by keyword."},{key:"google_ads_search",label:"Google Ads Transparency search",aliases:["google_ads_search","google ads search","ads transparency search"],credits:i(r.google_ads_search),unit:"per search",notes:"Browser automation to find advertisers in Google Ads Transparency Center by domain or name."},{key:"google_ads_intel",label:"Google Ads Transparency advertiser intel",aliases:["google_ads_page_intel","google ads intel","ads transparency intel"],credits:i(r.google_ads_intel),unit:"per call",notes:"Lists and hydrates an advertiser's creatives with image URLs and video references."},{key:"google_ads_transcribe",label:"Google ad video transcription",aliases:["google_ads_transcribe","google ad transcript"],credits:i(2e4),unit:"base + 2/min of video",notes:"Flat 200-credit base plus 2 credits per minute of video, reconciled to the real video length after transcription (e.g. a 10-minute video is about 220 credits)."},{key:"fb_transcribe",label:"Facebook video / ad transcription",aliases:["facebook_transcribe","facebook_video_transcribe","fb_transcribe","fb ad transcript"],credits:i(2e4),unit:"base + 2/min of video",notes:"Flat 200-credit base plus 2 credits per minute of video, reconciled to the real video length after transcription (e.g. a 10-minute video is about 220 credits)."},{key:"fb_reels_inventory",label:"Facebook Reel URL inventory",aliases:["facebook_reels_inventory","facebook reels","facebook reel urls","facebook profile reels"],credits:i(r.fb_reels_inventory),unit:"per profile scan",notes:"Collects canonical Reel URLs from a Facebook profile. Logged-out scans are capped at 60 URLs; saved browser profiles can request larger inventories."},{key:"tiktok_transcribe",label:"TikTok video transcription",aliases:["tiktok_video_transcribe","tiktok transcript"],credits:i(2e4),unit:"base + 2/min of video",notes:"Transcribes a public TikTok video from its playback media. Flat 200-credit base plus 2 credits per minute, reconciled after transcription."},{key:"instagram_profile",label:"Instagram profile content discovery",aliases:["instagram_profile_content","instagram profile","instagram content list","ig profile"],credits:i(r.instagram_profile),unit:"per profile scan",notes:"Browser extraction of public Instagram profile grid links. Complete history may require a logged-in profile."},{key:"instagram_media",label:"Instagram media download",aliases:["instagram_media_download","instagram reel download","instagram post download","ig media"],credits:i(r.instagram_media),unit:"per post or reel",notes:"Extracts post text, image URLs, and reel audio/video tracks, with local downloads when the server can write files."},{key:"instagram_transcribe",label:"Instagram media transcription",aliases:["instagram transcript","instagram reel transcript","ig transcribe"],credits:i(2e4),unit:"base + 2/min of video",notes:"Whisper transcription of selected Instagram audio/video media. Flat 200-credit base plus 2 credits per minute of video, reconciled to the real video length after transcription (e.g. a 10-minute video is about 220 credits)."},{key:"browser_minute",label:"Interactive browser session",aliases:["browser_open","browser agent","browser_agent","live browser","browse","browser control","interactive browser"],credits:i(r.browser_minute),unit:"per minute of use",notes:"Metered per minute of use for the whole time the browser session is open. Close the session to stop the meter; abandoned sessions are auto-closed after a short idle window."},{key:"reddit_thread",label:"Reddit thread base lookup",aliases:["reddit","reddit_thread","reddit comments","subreddit","reddit post"],credits:i(r.reddit_thread),unit:"per thread",notes:"Base lookup for the post itself. Comments billed separately per comment at reddit_comment rate. Refunded if the thread cannot be retrieved."},{key:"reddit_comment",label:"Reddit comment",aliases:["reddit_comment","reddit comments"],credits:i(r.reddit_comment),unit:"per comment",notes:"Charged per comment actually extracted, billed down automatically if the balance runs out mid-thread."},{key:"video_analysis",label:"Video breakdown (frame-by-frame + transcript)",aliases:["video_frame_analysis","video breakdown","video analysis","analyze video"],credits:i(r.video_analysis),unit:"per 120 frames (max 480)",notes:`Full video breakdown: samples frames across a video up to 60 minutes, analyzes visuals and audio, then produces a summary, pacing, topic outline, key points, hook, style, and replication guidance. Reserves ${i(r.video_analysis)} Credits per requested 120-frame tier, up to 480 frames. Unused frame tiers and failed-run frame charges are refunded. Incurred analysis-model usage is billed separately, including usage before a failure; terminal status checks settle the original run.`},{key:"trustpilot_reviews",label:"Trustpilot review harvest",aliases:["trustpilot_reviews","trustpilot","trustpilot reviews"],credits:i(r.trustpilot_reviews),unit:"per call",notes:"Base lookup. Reviews billed separately per card at trustpilot_review rate. Refunded if no reviews are found."},{key:"trustpilot_review",label:"Trustpilot review card",aliases:["trustpilot_review","trustpilot card"],credits:i(r.trustpilot_review),unit:"per review card",notes:"Charged per review actually extracted, billed down automatically if the balance runs out mid-page."},{key:"g2_reviews",label:"G2 review harvest",aliases:["g2_reviews","g2","g2 reviews"],credits:i(r.g2_reviews),unit:"per call",notes:"Base lookup. Reviews billed separately per card at g2_review rate. Refunded if no reviews are found."},{key:"g2_review",label:"G2 review card",aliases:["g2_review","g2 card"],credits:i(r.g2_review),unit:"per review card",notes:"Charged per review actually extracted (each card carries up to 3 Q&A sections), billed down automatically if the balance runs out mid-page."},{key:"diff_page",label:"Page change check",aliases:["diff_page","page diff","change detection"],credits:i(r.diff_page),unit:"per check",notes:"Same cost as a single page extract \u2014 one scrape is performed per check, then compared against your last stored snapshot for that URL."}],Ee="price_1Ta1NRS8aAcsk3TGwsRnYbix";function M(e){return e.billing_interval??"month"}function P(e){return e.billed_usd??e.monthly_usd}function k(e){return e.credits_mc/a}var u={price_1TmiHRS8aAcsk3TGwmSNfNIa:{tier:"starter",label:"Starter",price_id:"price_1TmiHRS8aAcsk3TGwmSNfNIa",monthly_usd:12,credits_mc:8e6,concurrency:3,intro_coupon:"mcp-starter-1dollar-intro-12"},price_1TrgihS8aAcsk3TG5cglrq4D:{tier:"growth",label:"Growth",price_id:"price_1TrgihS8aAcsk3TG5cglrq4D",monthly_usd:40,credits_mc:26666700,concurrency:10,intro_coupon:null},price_1TrgihS8aAcsk3TG4HnG4gbY:{tier:"scale",label:"Scale",price_id:"price_1TrgihS8aAcsk3TG4HnG4gbY",monthly_usd:100,credits_mc:8e7,concurrency:20,intro_coupon:null},price_1TwqIVS8aAcsk3TG0FE3ddDM:{tier:"sonic",label:"Sonic Annual",price_id:"price_1TwqIVS8aAcsk3TG0FE3ddDM",monthly_usd:25,billed_usd:300,credits_mc:25e7,concurrency:3,intro_coupon:null,billing_interval:"year",credits_never_expire:!0,private_offer:!0},price_1TwqIWS8aAcsk3TGbGbtlLak:{tier:"sonic-memory",label:"Sonic Annual + Memory Pro",price_id:"price_1TwqIWS8aAcsk3TGbGbtlLak",monthly_usd:34.5,billed_usd:414,credits_mc:25e7,concurrency:3,intro_coupon:null,billing_interval:"year",credits_never_expire:!0,includes_memory:!0,private_offer:!0}},b=Object.fromEntries(Object.values(u).map(e=>[e.tier,e])),f={sonic:{slug:"sonic",label:"Sonic annual partner offer",headline:"A full year of MCP Scraper, with Credits that never expire.",tier_keys:["sonic","sonic-memory"]}};function j(e){let t=Object.values(f).find(o=>o.tier_keys.includes(e));return t?`/${t.slug}/claim`:null}function Q(e){return e?Object.values(f).find(t=>t.tier_keys.includes(e))??null:null}function ge(e,t){let o=Q(e);return o?!o.tier_keys.includes(t):!1}function Re(e){if(!e)return null;let t=b[e];return t?{tier:t.tier,label:t.label,amount_usd:P(t),interval:M(t),monthly_equivalent_usd:t.monthly_usd,credits_per_interval:k(t),concurrency:t.concurrency,credits_never_expire:!!t.credits_never_expire,includes_memory:!!t.includes_memory,private_offer:!!t.private_offer,offer_claim_path:j(t.tier)}:null}function be(e){let t=f[e];if(!t)return null;let o=t.tier_keys.map(n=>b[n]).filter(n=>!!n).map(n=>({tier:n.tier,label:n.label,amount_usd:P(n),interval:M(n),monthly_equivalent_usd:n.monthly_usd,credits:k(n),credits_never_expire:!!n.credits_never_expire,includes_memory:!!n.includes_memory,concurrency:n.concurrency}));return o.length?{slug:t.slug,label:t.label,headline:t.headline,options:o}:null}function fe(){let e=b.starter,t=W.map(({aliases:s,...c})=>({...c,...c.notes?{notes:c.notes.replace(/ via fal\.ai/g,"")}:{}})),o=Object.fromEntries(t.map(s=>[s.key,{credits:s.credits,unit:s.unit,label:s.label,...s.notes?{notes:s.notes}:{}}])),n=Object.values(u).filter(s=>!s.private_offer).map(s=>({tier:s.tier,label:s.label,monthlyUsd:s.monthly_usd,credits:s.credits_mc/a,concurrency:s.concurrency}));return{...E,operationCosts:o,publicTiers:n,concurrencyPack:{ratePolicyVersion:U,monthlyUsd:x,currency:D,interval:w,billingUnit:"pack",slotsPerPack:R},scaleCreditPack:{ratePolicyVersion:X,eligibleTier:"scale",incrementUsd:L,creditsPerIncrement:C,maxQuantity:J,currency:"usd",expiryMonths:3},creditsPerDollarStarter:Math.round(i(e.credits_mc)/e.monthly_usd),costs:t,connectedAccounts:E.addons.connectedAccounts,listingWrites:K}}var x=5,D="usd",w="month",R=2,U="2026-08-14.concurrency-pack-v1",Z="$5/month for 2 extra browsers",Ce="MCP Scraper browser concurrency pack \u2014 each $5 monthly pack adds 2 browsers.",Te="Billed monthly until canceled. A receipt is emailed after each successful payment.",S="npx -y -p mcp-scraper@latest mcp-scraper-cli billing concurrency checkout",X="2026-09-21.scale-credit-pack-v1",L=10,C=8e4,Se=C*a,J=100;function ye(){let e=process.env.CONCURRENCY_BILLING_URL??"https://mcpscraper.dev/billing";return{product:"Extra browser concurrency pack",rate_policy_version:U,price_label:Z,unit_amount_usd:x,currency:D,interval:w,billing_unit:"pack",pack_quantity:1,slots_per_pack:R,extra_slots:R,billing_url:e,terminal_command:S,terminal_command_with_api_key_env:`MCP_SCRAPER_API_KEY=sk_live_your_key ${S}`}}function i(e){return e/a}var z="npx -y -p mcp-scraper@latest mcp-scraper-cli billing subscribe";function ee(){return Object.values(u).filter(e=>!e.private_offer).sort((e,t)=>e.credits_mc-t.credits_mc)}function Ae(e,t){let o=process.env.TOPUP_URL??"https://mcpscraper.dev/billing",n=i(e),s=i(t),c=ee().map(m=>m.tier).join("|"),d=`${z} <${c}>`;return{error:"insufficient_balance",error_code:"insufficient_balance",message:`Insufficient credits. Balance: ${n} credits. This call requires ${s} credits. Credits refresh when your plan renews. Scale customers can buy ${C} Credits per $${L} increment; other customers can move to a larger plan at ${o} (terminal: ${d})`,balance_credits:n,required_credits:s,topup_url:o,upgrade_command:d}}var re=1e7*1,he={price_1TnMSTS8aAcsk3TGBgiwuvqL:{plan:"pro",label:"Pro",price_id:"price_1TnMSTS8aAcsk3TGBgiwuvqL",interval:"month",monthly_usd:19,quota_bytes:5e9},price_1TnMSTS8aAcsk3TGWBVU2agY:{plan:"pro",label:"Pro",price_id:"price_1TnMSTS8aAcsk3TGWBVU2agY",interval:"year",monthly_usd:19,quota_bytes:5e9}},Ne={free:re,pro:5e9,team:5e10},te=3;var Ie=19/te,ve=3,Oe=1.5,Me=1.5,G=2e4,F=200;function Pe(e){let t=Math.max(1,Math.ceil((e||60)/60));return G+F*t}var ke=G+F*30,xe=u.price_1TmiHRS8aAcsk3TGwmSNfNIa.credits_mc/u.price_1TmiHRS8aAcsk3TGwmSNfNIa.monthly_usd;export{r as a,B as b,Y as c,a as d,_ as e,q as f,ae as g,oe as h,ce as i,H as j,_e as k,le as l,de as m,K as n,$ as o,y as p,pe as q,A as r,h as s,N as t,I as u,ue as v,me as w,W as x,Ee as y,M as z,P as A,k as B,u as C,b as D,j as E,Q as F,ge as G,Re as H,be as I,fe as J,x as K,R as L,Ce as M,Te as N,L as O,C as P,Se as Q,J as R,ye as S,i as T,Ae as U,he as V,Ne as W,ve as X,Oe as Y,Me as Z,G as _,F as $,Pe as aa,ke as ba,xe as ca};
|
package/dist/chunk-4ZVO6GX4.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{AsyncLocalStorage as n}from"async_hooks";var s="MCP_SCRAPER_ALLOW_HEADLESS_HARVEST_TEST",t=new n;function u(e,o){return t.run(e,o)}function l(){return t.getStore()}export{s as a,u as b,l as c};
|
package/dist/chunk-55ZANTHL.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{e as _,j as y}from"./chunk-SEZETSB3.js";import{i as w}from"./chunk-SDQW7IJN.js";import{b as A}from"./chunk-B3JRL45T.js";import{c as h}from"./chunk-OILOHQNL.js";import{join as S}from"path";import{randomBytes as B}from"crypto";import{ZipFile as D}from"yazl";import v from"p-limit";var E="maps-media/",N=10080*60*1e3,L=900*1e3,m=5*1024*1024,O=40*1024*1024,U=15e5,k=25e5,j=6,I=4;function T(){return process.env.MAPS_MEDIA_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 b(){return{prefix:E,artifactTtlMs:N,downloadTtlMs:L,token:T()}}function f(e){try{let t=new URL(e);if(t.protocol!=="https:")return null;let r=t.hostname.toLowerCase().replace(/\.$/,"");return r!=="googleusercontent.com"&&!r.endsWith(".googleusercontent.com")&&r!=="streetviewpixels-pa.googleapis.com"?null:t}catch{return null}}function F(e){let t=f(e);return t?(t.hostname.toLowerCase().endsWith("googleusercontent.com")&&/=[^/]+$/.test(t.pathname)&&(t.pathname=t.pathname.replace(/=[^/]+$/,"=s2048")),t.href):e}function $(e){return e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255?{mimeType:"image/jpeg",extension:"jpg"}:e.length>=8&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71?{mimeType:"image/png",extension:"png"}:e.length>=12&&String.fromCharCode(...e.slice(0,4))==="RIFF"&&String.fromCharCode(...e.slice(8,12))==="WEBP"?{mimeType:"image/webp",extension:"webp"}:e.length>=6&&["GIF87a","GIF89a"].includes(String.fromCharCode(...e.slice(0,6)))?{mimeType:"image/gif",extension:"gif"}:null}async function G(e){let t=Number(e.headers.get("content-length")??"");if(Number.isFinite(t)&&t>m)throw new Error("image_too_large");if(!e.body){let s=new Uint8Array(await e.arrayBuffer());if(s.byteLength>m)throw new Error("image_too_large");return s}let r=e.body.getReader(),l=[],a=0;try{for(;;){let{done:s,value:c}=await r.read();if(s)break;if(c){if(a+=c.byteLength,a>m)throw new Error("image_too_large");l.push(c)}}}finally{r.releaseLock()}let o=new Uint8Array(a),d=0;for(let s of l)o.set(s,d),d+=s.byteLength;return o}async function W(e,t){let r=f(F(e));if(!r)throw new Error("image_host_not_allowed");for(let l=0;l<=I;l+=1){let a=await A(r.href,{field:"Maps image URL"});if(a.error||!a.parsed)throw new Error("image_url_rejected");let o=await fetch(a.parsed.href,{redirect:"manual",headers:{Accept:"image/jpeg,image/png,image/webp,image/gif;q=0.8"},signal:t?AbortSignal.any([t,AbortSignal.timeout(15e3)]):AbortSignal.timeout(15e3)});if([301,302,303,307,308].includes(o.status)){let c=o.headers.get("location");if(!c||l===I)throw new Error("image_redirect_rejected");if(r=f(new URL(c,r).href),!r)throw new Error("image_redirect_host_not_allowed");continue}if(!o.ok)throw new Error(`image_fetch_${o.status}`);let d=await G(o),s=$(d);if(!s)throw new Error("image_content_invalid");return{bytes:Buffer.from(d),...s,finalUrl:r.href}}throw new Error("image_redirect_rejected")}function z(e){return new Promise((t,r)=>{let l=new D,a=[];l.outputStream.on("data",o=>a.push(Buffer.from(o))),l.outputStream.once("error",r),l.outputStream.once("end",()=>t(Buffer.concat(a)));for(let o of e)l.addBuffer(o.content,o.path);l.end()})}function X(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,70)||"google-maps-place"}function K(e){return w(e,E)}async function ee(e){return K(e.artifactId)!==e.ownerId?null:y({policy:b(),artifactId:e.artifactId,maxBytes:50*1024*1024})}async function te(e){let t=new AbortController,r=e.deadlineMs?setTimeout(()=>t.abort(new Error("maps_media_packaging_deadline")),Math.max(1,e.deadlineMs-Date.now())):null,l=v(j),a=[],o=0,d=0,s=0,c=e.media.images.map(n=>l(async()=>{if(!t.signal.aborted){try{let i=await W(n.sourceUrl,t.signal);if(o+i.bytes.length>O)throw new Error("archive_byte_limit_reached");o+=i.bytes.length;let g=`images/${String(n.index).padStart(4,"0")}-${n.origin}.${i.extension}`;a.push({path:g,content:i.bytes}),n.sourceUrl=i.finalUrl,n.filename=g,n.mimeType=i.mimeType,n.bytes=i.bytes.length,n.downloadStatus="downloaded",n.downloadError=null,s<e.maxInlineImages&&i.bytes.length<=U&&d+i.bytes.length<=k&&(n.inlinePreview={data:i.bytes.toString("base64"),mimeType:i.mimeType},d+=i.bytes.length,s+=1)}catch(i){if(t.signal.aborted)return;n.filename=null,n.mimeType=null,n.bytes=null,n.downloadStatus="failed",n.downloadError=i instanceof Error?i.message:"image_download_failed",n.inlinePreview=null}t.signal.aborted||await e.onImage?.(n)}}));try{if(await Promise.all(c),t.signal.aborted)throw new Error("maps_media_packaging_deadline")}catch(n){throw t.abort(n),await Promise.allSettled(c),n}finally{r&&clearTimeout(r)}e.media.imagesDownloaded=e.media.images.filter(n=>n.downloadStatus==="downloaded").length;let u=e.media.images.length-e.media.imagesDownloaded;if(u>0&&e.media.warnings.push(`${u} image(s) could not be downloaded; their manifest rows include a bounded error code.`),e.media.imagesDownloaded===0)return{media:e.media,artifact:null};let M=e.media.images.map(({inlinePreview:n,...i})=>i),x={businessName:e.businessName,placeUrl:e.placeUrl,extractedAt:e.extractedAt,scope:e.media.scope,imagesCollected:e.media.imagesCollected,imagesDownloaded:e.media.imagesDownloaded,ownerImagesCollected:e.media.ownerImagesCollected,otherImagesCollected:e.media.otherImagesCollected,unknownOriginImagesCollected:e.media.unknownOriginImagesCollected,ownerGalleryExhausted:e.media.ownerGalleryExhausted,galleryExhausted:e.media.exhausted,stopReason:e.media.stopReason,notes:["origin=owner is backed by the Google Maps By owner gallery or an exact media-key match to it.","origin=other means absent from an exhausted owner gallery; it can include customer, review, Street View, Google, or unattributed media.","Google-hosted photo files use a bounded s2048 rendition when that CDN form is available; each file is still subject to byte and signature validation."]};a.push({path:"summary.json",content:Buffer.from(JSON.stringify(x,null,2))}),a.push({path:"images.jsonl",content:Buffer.from(M.map(n=>JSON.stringify(n)).join(`
|
|
2
|
-
`)+`
|
|
3
|
-
`)});let R=await z(a),C=B(6).toString("hex"),p=await _({policy:b(),ownerId:e.ownerId,artifactKey:`${C}.zip`,createdAt:new Date(e.extractedAt),filename:`${X(e.businessName)}-maps-images.zip`,contentType:"application/zip",content:R}),P=T()?null:S(h(),"blobs",p.artifactId);return{media:e.media,artifact:{...p,localPath:P}}}export{E as a,N as b,b as c,K as d,ee as e,te as f};
|