@iflow-mcp/jakeliume-webpeel 0.22.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/LICENSE +15 -0
- package/README.md +313 -0
- package/dist/cache.d.ts +30 -0
- package/dist/cache.js +139 -0
- package/dist/cli/commands/auth.d.ts +5 -0
- package/dist/cli/commands/auth.js +411 -0
- package/dist/cli/commands/doctor.d.ts +37 -0
- package/dist/cli/commands/doctor.js +371 -0
- package/dist/cli/commands/fetch.d.ts +6 -0
- package/dist/cli/commands/fetch.js +1345 -0
- package/dist/cli/commands/guide.d.ts +2 -0
- package/dist/cli/commands/guide.js +183 -0
- package/dist/cli/commands/interact.d.ts +5 -0
- package/dist/cli/commands/interact.js +840 -0
- package/dist/cli/commands/jobs.d.ts +5 -0
- package/dist/cli/commands/jobs.js +997 -0
- package/dist/cli/commands/monitor.d.ts +12 -0
- package/dist/cli/commands/monitor.js +197 -0
- package/dist/cli/commands/observe.d.ts +12 -0
- package/dist/cli/commands/observe.js +158 -0
- package/dist/cli/commands/screenshot.d.ts +5 -0
- package/dist/cli/commands/screenshot.js +282 -0
- package/dist/cli/commands/search.d.ts +5 -0
- package/dist/cli/commands/search.js +1021 -0
- package/dist/cli/commands/setup.d.ts +13 -0
- package/dist/cli/commands/setup.js +244 -0
- package/dist/cli/commands/skill.d.ts +15 -0
- package/dist/cli/commands/skill.js +195 -0
- package/dist/cli/utils.d.ts +84 -0
- package/dist/cli/utils.js +806 -0
- package/dist/cli-auth.d.ts +75 -0
- package/dist/cli-auth.js +369 -0
- package/dist/cli.d.ts +17 -0
- package/dist/cli.js +99 -0
- package/dist/core/actions.d.ts +69 -0
- package/dist/core/actions.js +495 -0
- package/dist/core/agent.d.ts +98 -0
- package/dist/core/agent.js +558 -0
- package/dist/core/answer.d.ts +42 -0
- package/dist/core/answer.js +395 -0
- package/dist/core/application-tracker.d.ts +84 -0
- package/dist/core/application-tracker.js +184 -0
- package/dist/core/apply.d.ts +162 -0
- package/dist/core/apply.js +816 -0
- package/dist/core/auth-detection.d.ts +35 -0
- package/dist/core/auth-detection.js +358 -0
- package/dist/core/auto-extract.d.ts +82 -0
- package/dist/core/auto-extract.js +604 -0
- package/dist/core/auto-interact.d.ts +23 -0
- package/dist/core/auto-interact.js +246 -0
- package/dist/core/bm25-filter.d.ts +66 -0
- package/dist/core/bm25-filter.js +288 -0
- package/dist/core/branding.d.ts +54 -0
- package/dist/core/branding.js +234 -0
- package/dist/core/browser-fetch.d.ts +323 -0
- package/dist/core/browser-fetch.js +1600 -0
- package/dist/core/browser-pool.d.ts +91 -0
- package/dist/core/browser-pool.js +550 -0
- package/dist/core/budget.d.ts +42 -0
- package/dist/core/budget.js +324 -0
- package/dist/core/business-intel.d.ts +47 -0
- package/dist/core/business-intel.js +279 -0
- package/dist/core/cache.d.ts +13 -0
- package/dist/core/cache.js +121 -0
- package/dist/core/cf-worker-proxy.d.ts +32 -0
- package/dist/core/cf-worker-proxy.js +87 -0
- package/dist/core/challenge-detection.d.ts +26 -0
- package/dist/core/challenge-detection.js +468 -0
- package/dist/core/change-tracking.d.ts +75 -0
- package/dist/core/change-tracking.js +276 -0
- package/dist/core/chunker.d.ts +46 -0
- package/dist/core/chunker.js +249 -0
- package/dist/core/chunking.d.ts +42 -0
- package/dist/core/chunking.js +181 -0
- package/dist/core/circuit-breaker.d.ts +44 -0
- package/dist/core/circuit-breaker.js +85 -0
- package/dist/core/content-pruner.d.ts +47 -0
- package/dist/core/content-pruner.js +425 -0
- package/dist/core/cookie-cache.d.ts +60 -0
- package/dist/core/cookie-cache.js +163 -0
- package/dist/core/crawl-checkpoint.d.ts +54 -0
- package/dist/core/crawl-checkpoint.js +104 -0
- package/dist/core/crawler.d.ts +84 -0
- package/dist/core/crawler.js +349 -0
- package/dist/core/cross-verify.d.ts +27 -0
- package/dist/core/cross-verify.js +93 -0
- package/dist/core/deep-fetch.d.ts +74 -0
- package/dist/core/deep-fetch.js +405 -0
- package/dist/core/deep-research.d.ts +141 -0
- package/dist/core/deep-research.js +972 -0
- package/dist/core/design-analysis.d.ts +70 -0
- package/dist/core/design-analysis.js +490 -0
- package/dist/core/design-compare.d.ts +38 -0
- package/dist/core/design-compare.js +264 -0
- package/dist/core/diff.d.ts +61 -0
- package/dist/core/diff.js +289 -0
- package/dist/core/dns-cache.d.ts +20 -0
- package/dist/core/dns-cache.js +198 -0
- package/dist/core/documents.d.ts +23 -0
- package/dist/core/documents.js +123 -0
- package/dist/core/domain-memory.d.ts +66 -0
- package/dist/core/domain-memory.js +163 -0
- package/dist/core/domain-verify.d.ts +40 -0
- package/dist/core/domain-verify.js +379 -0
- package/dist/core/engine-ranker.d.ts +112 -0
- package/dist/core/engine-ranker.js +395 -0
- package/dist/core/extract-inline.d.ts +38 -0
- package/dist/core/extract-inline.js +215 -0
- package/dist/core/extract-listings.d.ts +38 -0
- package/dist/core/extract-listings.js +461 -0
- package/dist/core/extract.d.ts +9 -0
- package/dist/core/extract.js +139 -0
- package/dist/core/fetch-cache.d.ts +57 -0
- package/dist/core/fetch-cache.js +95 -0
- package/dist/core/fetcher.d.ts +13 -0
- package/dist/core/fetcher.js +12 -0
- package/dist/core/google-cache.d.ts +29 -0
- package/dist/core/google-cache.js +180 -0
- package/dist/core/google-serp-parser.d.ts +82 -0
- package/dist/core/google-serp-parser.js +287 -0
- package/dist/core/hotel-search.d.ts +122 -0
- package/dist/core/hotel-search.js +382 -0
- package/dist/core/http-fetch.d.ts +72 -0
- package/dist/core/http-fetch.js +820 -0
- package/dist/core/human.d.ts +175 -0
- package/dist/core/human.js +680 -0
- package/dist/core/image-caption.d.ts +44 -0
- package/dist/core/image-caption.js +271 -0
- package/dist/core/jobs.d.ts +75 -0
- package/dist/core/jobs.js +634 -0
- package/dist/core/json-ld.d.ts +15 -0
- package/dist/core/json-ld.js +617 -0
- package/dist/core/language-detect.d.ts +18 -0
- package/dist/core/language-detect.js +135 -0
- package/dist/core/links.d.ts +10 -0
- package/dist/core/links.js +44 -0
- package/dist/core/llm-extract.d.ts +71 -0
- package/dist/core/llm-extract.js +507 -0
- package/dist/core/llm-provider.d.ts +100 -0
- package/dist/core/llm-provider.js +702 -0
- package/dist/core/local-search.d.ts +60 -0
- package/dist/core/local-search.js +308 -0
- package/dist/core/logger.d.ts +28 -0
- package/dist/core/logger.js +104 -0
- package/dist/core/map.d.ts +33 -0
- package/dist/core/map.js +127 -0
- package/dist/core/markdown.d.ts +92 -0
- package/dist/core/markdown.js +809 -0
- package/dist/core/metadata.d.ts +34 -0
- package/dist/core/metadata.js +422 -0
- package/dist/core/observe.d.ts +113 -0
- package/dist/core/observe.js +395 -0
- package/dist/core/ocr.d.ts +12 -0
- package/dist/core/ocr.js +33 -0
- package/dist/core/paginate.d.ts +31 -0
- package/dist/core/paginate.js +106 -0
- package/dist/core/pdf.d.ts +8 -0
- package/dist/core/pdf.js +25 -0
- package/dist/core/peel-tls.d.ts +25 -0
- package/dist/core/peel-tls.js +220 -0
- package/dist/core/pipeline.d.ts +132 -0
- package/dist/core/pipeline.js +1666 -0
- package/dist/core/profiles.d.ts +61 -0
- package/dist/core/profiles.js +350 -0
- package/dist/core/prompt-guard.d.ts +30 -0
- package/dist/core/prompt-guard.js +119 -0
- package/dist/core/proxy-config.d.ts +90 -0
- package/dist/core/proxy-config.js +172 -0
- package/dist/core/quick-answer.d.ts +53 -0
- package/dist/core/quick-answer.js +833 -0
- package/dist/core/rate-governor.d.ts +80 -0
- package/dist/core/rate-governor.js +238 -0
- package/dist/core/readability.d.ts +57 -0
- package/dist/core/readability.js +533 -0
- package/dist/core/research.d.ts +66 -0
- package/dist/core/research.js +270 -0
- package/dist/core/retry.d.ts +60 -0
- package/dist/core/retry.js +119 -0
- package/dist/core/safe-browsing.d.ts +30 -0
- package/dist/core/safe-browsing.js +206 -0
- package/dist/core/schema-extraction.d.ts +66 -0
- package/dist/core/schema-extraction.js +352 -0
- package/dist/core/schema-postprocess.d.ts +32 -0
- package/dist/core/schema-postprocess.js +469 -0
- package/dist/core/schema-templates.d.ts +19 -0
- package/dist/core/schema-templates.js +143 -0
- package/dist/core/screenshot.d.ts +224 -0
- package/dist/core/screenshot.js +207 -0
- package/dist/core/search-engines.d.ts +25 -0
- package/dist/core/search-engines.js +182 -0
- package/dist/core/search-provider.d.ts +243 -0
- package/dist/core/search-provider.js +1629 -0
- package/dist/core/searxng-provider.d.ts +35 -0
- package/dist/core/searxng-provider.js +105 -0
- package/dist/core/selective-evidence.d.ts +151 -0
- package/dist/core/selective-evidence.js +389 -0
- package/dist/core/site-search.d.ts +44 -0
- package/dist/core/site-search.js +252 -0
- package/dist/core/sitemap.d.ts +23 -0
- package/dist/core/sitemap.js +105 -0
- package/dist/core/source-credibility.d.ts +29 -0
- package/dist/core/source-credibility.js +584 -0
- package/dist/core/source-scoring.d.ts +166 -0
- package/dist/core/source-scoring.js +396 -0
- package/dist/core/stemmer.d.ts +38 -0
- package/dist/core/stemmer.js +509 -0
- package/dist/core/strategies.d.ts +104 -0
- package/dist/core/strategies.js +1044 -0
- package/dist/core/strategy-hooks.d.ts +145 -0
- package/dist/core/strategy-hooks.js +74 -0
- package/dist/core/structured-extract.d.ts +43 -0
- package/dist/core/structured-extract.js +550 -0
- package/dist/core/summarize.d.ts +17 -0
- package/dist/core/summarize.js +78 -0
- package/dist/core/synonyms.d.ts +42 -0
- package/dist/core/synonyms.js +184 -0
- package/dist/core/system-monitor.d.ts +61 -0
- package/dist/core/system-monitor.js +133 -0
- package/dist/core/table-format.d.ts +30 -0
- package/dist/core/table-format.js +146 -0
- package/dist/core/threat-feeds.d.ts +23 -0
- package/dist/core/threat-feeds.js +104 -0
- package/dist/core/timing.d.ts +21 -0
- package/dist/core/timing.js +33 -0
- package/dist/core/transcript-export.d.ts +47 -0
- package/dist/core/transcript-export.js +107 -0
- package/dist/core/user-agents.d.ts +82 -0
- package/dist/core/user-agents.js +239 -0
- package/dist/core/vertical-search.d.ts +54 -0
- package/dist/core/vertical-search.js +158 -0
- package/dist/core/watch-manager.d.ts +175 -0
- package/dist/core/watch-manager.js +416 -0
- package/dist/core/watch.d.ts +101 -0
- package/dist/core/watch.js +389 -0
- package/dist/core/youtube.d.ts +130 -0
- package/dist/core/youtube.js +1175 -0
- package/dist/ee/challenge-re-export.d.ts +1 -0
- package/dist/ee/challenge-re-export.js +1 -0
- package/dist/ee/challenge-solver.d.ts +72 -0
- package/dist/ee/challenge-solver.js +720 -0
- package/dist/ee/domain-extractors.d.ts +8 -0
- package/dist/ee/domain-extractors.js +8 -0
- package/dist/ee/domain-intel.d.ts +16 -0
- package/dist/ee/domain-intel.js +133 -0
- package/dist/ee/extractors/allrecipes.d.ts +2 -0
- package/dist/ee/extractors/allrecipes.js +120 -0
- package/dist/ee/extractors/amazon.d.ts +2 -0
- package/dist/ee/extractors/amazon.js +78 -0
- package/dist/ee/extractors/arxiv.d.ts +2 -0
- package/dist/ee/extractors/arxiv.js +137 -0
- package/dist/ee/extractors/bestbuy.d.ts +2 -0
- package/dist/ee/extractors/bestbuy.js +78 -0
- package/dist/ee/extractors/carscom.d.ts +2 -0
- package/dist/ee/extractors/carscom.js +121 -0
- package/dist/ee/extractors/coingecko.d.ts +2 -0
- package/dist/ee/extractors/coingecko.js +134 -0
- package/dist/ee/extractors/craigslist.d.ts +2 -0
- package/dist/ee/extractors/craigslist.js +92 -0
- package/dist/ee/extractors/devto.d.ts +2 -0
- package/dist/ee/extractors/devto.js +135 -0
- package/dist/ee/extractors/ebay.d.ts +2 -0
- package/dist/ee/extractors/ebay.js +90 -0
- package/dist/ee/extractors/espn.d.ts +2 -0
- package/dist/ee/extractors/espn.js +260 -0
- package/dist/ee/extractors/etsy.d.ts +2 -0
- package/dist/ee/extractors/etsy.js +52 -0
- package/dist/ee/extractors/facebook.d.ts +2 -0
- package/dist/ee/extractors/facebook.js +46 -0
- package/dist/ee/extractors/github.d.ts +2 -0
- package/dist/ee/extractors/github.js +196 -0
- package/dist/ee/extractors/google-flights.d.ts +2 -0
- package/dist/ee/extractors/google-flights.js +176 -0
- package/dist/ee/extractors/hackernews.d.ts +2 -0
- package/dist/ee/extractors/hackernews.js +147 -0
- package/dist/ee/extractors/imdb.d.ts +2 -0
- package/dist/ee/extractors/imdb.js +172 -0
- package/dist/ee/extractors/index.d.ts +26 -0
- package/dist/ee/extractors/index.js +247 -0
- package/dist/ee/extractors/instagram.d.ts +2 -0
- package/dist/ee/extractors/instagram.js +102 -0
- package/dist/ee/extractors/kalshi.d.ts +2 -0
- package/dist/ee/extractors/kalshi.js +121 -0
- package/dist/ee/extractors/kayak-cars.d.ts +2 -0
- package/dist/ee/extractors/kayak-cars.js +270 -0
- package/dist/ee/extractors/linkedin.d.ts +2 -0
- package/dist/ee/extractors/linkedin.js +113 -0
- package/dist/ee/extractors/medium.d.ts +2 -0
- package/dist/ee/extractors/medium.js +130 -0
- package/dist/ee/extractors/news.d.ts +4 -0
- package/dist/ee/extractors/news.js +173 -0
- package/dist/ee/extractors/npm.d.ts +2 -0
- package/dist/ee/extractors/npm.js +86 -0
- package/dist/ee/extractors/pdf.d.ts +2 -0
- package/dist/ee/extractors/pdf.js +108 -0
- package/dist/ee/extractors/pinterest.d.ts +2 -0
- package/dist/ee/extractors/pinterest.js +34 -0
- package/dist/ee/extractors/polymarket.d.ts +2 -0
- package/dist/ee/extractors/polymarket.js +358 -0
- package/dist/ee/extractors/producthunt.d.ts +2 -0
- package/dist/ee/extractors/producthunt.js +88 -0
- package/dist/ee/extractors/pubmed.d.ts +2 -0
- package/dist/ee/extractors/pubmed.js +162 -0
- package/dist/ee/extractors/pypi.d.ts +2 -0
- package/dist/ee/extractors/pypi.js +80 -0
- package/dist/ee/extractors/reddit.d.ts +2 -0
- package/dist/ee/extractors/reddit.js +438 -0
- package/dist/ee/extractors/redfin.d.ts +2 -0
- package/dist/ee/extractors/redfin.js +156 -0
- package/dist/ee/extractors/semanticscholar.d.ts +2 -0
- package/dist/ee/extractors/semanticscholar.js +131 -0
- package/dist/ee/extractors/shared.d.ts +12 -0
- package/dist/ee/extractors/shared.js +76 -0
- package/dist/ee/extractors/soundcloud.d.ts +2 -0
- package/dist/ee/extractors/soundcloud.js +34 -0
- package/dist/ee/extractors/sportsbetting.d.ts +2 -0
- package/dist/ee/extractors/sportsbetting.js +37 -0
- package/dist/ee/extractors/spotify.d.ts +2 -0
- package/dist/ee/extractors/spotify.js +34 -0
- package/dist/ee/extractors/stackoverflow.d.ts +2 -0
- package/dist/ee/extractors/stackoverflow.js +61 -0
- package/dist/ee/extractors/substack.d.ts +2 -0
- package/dist/ee/extractors/substack.js +115 -0
- package/dist/ee/extractors/substackroot.d.ts +2 -0
- package/dist/ee/extractors/substackroot.js +46 -0
- package/dist/ee/extractors/tiktok.d.ts +2 -0
- package/dist/ee/extractors/tiktok.js +29 -0
- package/dist/ee/extractors/tradingview.d.ts +2 -0
- package/dist/ee/extractors/tradingview.js +182 -0
- package/dist/ee/extractors/twitch.d.ts +2 -0
- package/dist/ee/extractors/twitch.js +36 -0
- package/dist/ee/extractors/twitter.d.ts +2 -0
- package/dist/ee/extractors/twitter.js +327 -0
- package/dist/ee/extractors/types.d.ts +14 -0
- package/dist/ee/extractors/types.js +1 -0
- package/dist/ee/extractors/walmart.d.ts +2 -0
- package/dist/ee/extractors/walmart.js +50 -0
- package/dist/ee/extractors/weather.d.ts +2 -0
- package/dist/ee/extractors/weather.js +133 -0
- package/dist/ee/extractors/wikipedia.d.ts +4 -0
- package/dist/ee/extractors/wikipedia.js +235 -0
- package/dist/ee/extractors/yelp.d.ts +2 -0
- package/dist/ee/extractors/yelp.js +216 -0
- package/dist/ee/extractors/youtube.d.ts +2 -0
- package/dist/ee/extractors/youtube.js +189 -0
- package/dist/ee/extractors/zillow.d.ts +54 -0
- package/dist/ee/extractors/zillow.js +247 -0
- package/dist/ee/extractors-re-export.d.ts +1 -0
- package/dist/ee/extractors-re-export.js +1 -0
- package/dist/ee/premium-hooks.d.ts +20 -0
- package/dist/ee/premium-hooks.js +50 -0
- package/dist/ee/spa-detection.d.ts +2 -0
- package/dist/ee/spa-detection.js +2 -0
- package/dist/ee/stability.d.ts +4 -0
- package/dist/ee/stability.js +29 -0
- package/dist/ee/swr-cache.d.ts +14 -0
- package/dist/ee/swr-cache.js +34 -0
- package/dist/index.d.ts +143 -0
- package/dist/index.js +291 -0
- package/dist/integrations/index.d.ts +2 -0
- package/dist/integrations/index.js +2 -0
- package/dist/integrations/langchain.d.ts +64 -0
- package/dist/integrations/langchain.js +115 -0
- package/dist/integrations/llamaindex.d.ts +50 -0
- package/dist/integrations/llamaindex.js +91 -0
- package/dist/mcp/handlers/act.d.ts +5 -0
- package/dist/mcp/handlers/act.js +34 -0
- package/dist/mcp/handlers/definitions.d.ts +6 -0
- package/dist/mcp/handlers/definitions.js +395 -0
- package/dist/mcp/handlers/extract.d.ts +7 -0
- package/dist/mcp/handlers/extract.js +135 -0
- package/dist/mcp/handlers/fetch.d.ts +6 -0
- package/dist/mcp/handlers/fetch.js +98 -0
- package/dist/mcp/handlers/find.d.ts +5 -0
- package/dist/mcp/handlers/find.js +137 -0
- package/dist/mcp/handlers/index.d.ts +13 -0
- package/dist/mcp/handlers/index.js +63 -0
- package/dist/mcp/handlers/legacy.d.ts +25 -0
- package/dist/mcp/handlers/legacy.js +450 -0
- package/dist/mcp/handlers/meta.d.ts +6 -0
- package/dist/mcp/handlers/meta.js +40 -0
- package/dist/mcp/handlers/monitor.d.ts +5 -0
- package/dist/mcp/handlers/monitor.js +41 -0
- package/dist/mcp/handlers/observe.d.ts +8 -0
- package/dist/mcp/handlers/observe.js +37 -0
- package/dist/mcp/handlers/read.d.ts +6 -0
- package/dist/mcp/handlers/read.js +78 -0
- package/dist/mcp/handlers/see.d.ts +5 -0
- package/dist/mcp/handlers/see.js +75 -0
- package/dist/mcp/handlers/types.d.ts +29 -0
- package/dist/mcp/handlers/types.js +28 -0
- package/dist/mcp/server.d.ts +7 -0
- package/dist/mcp/server.js +108 -0
- package/dist/mcp/smart-router.d.ts +23 -0
- package/dist/mcp/smart-router.js +178 -0
- package/dist/server/app.d.ts +14 -0
- package/dist/server/app.js +632 -0
- package/dist/server/auth-store.d.ts +28 -0
- package/dist/server/auth-store.js +88 -0
- package/dist/server/bull-queues.d.ts +60 -0
- package/dist/server/bull-queues.js +90 -0
- package/dist/server/email-service.d.ts +55 -0
- package/dist/server/email-service.js +291 -0
- package/dist/server/job-queue.d.ts +100 -0
- package/dist/server/job-queue.js +145 -0
- package/dist/server/logger.d.ts +10 -0
- package/dist/server/logger.js +37 -0
- package/dist/server/middleware/audit-log.d.ts +14 -0
- package/dist/server/middleware/audit-log.js +73 -0
- package/dist/server/middleware/auth.d.ts +35 -0
- package/dist/server/middleware/auth.js +225 -0
- package/dist/server/middleware/rate-limit.d.ts +50 -0
- package/dist/server/middleware/rate-limit.js +270 -0
- package/dist/server/middleware/scope-guard.d.ts +25 -0
- package/dist/server/middleware/scope-guard.js +45 -0
- package/dist/server/middleware/url-validator.d.ts +15 -0
- package/dist/server/middleware/url-validator.js +201 -0
- package/dist/server/openapi.yaml +6418 -0
- package/dist/server/pg-auth-store.d.ts +146 -0
- package/dist/server/pg-auth-store.js +576 -0
- package/dist/server/pg-job-queue.d.ts +59 -0
- package/dist/server/pg-job-queue.js +375 -0
- package/dist/server/routes/activity.d.ts +6 -0
- package/dist/server/routes/activity.js +79 -0
- package/dist/server/routes/admin-active.d.ts +7 -0
- package/dist/server/routes/admin-active.js +120 -0
- package/dist/server/routes/admin-stats.d.ts +7 -0
- package/dist/server/routes/admin-stats.js +176 -0
- package/dist/server/routes/agent.d.ts +24 -0
- package/dist/server/routes/agent.js +480 -0
- package/dist/server/routes/answer.d.ts +5 -0
- package/dist/server/routes/answer.js +125 -0
- package/dist/server/routes/ask.d.ts +28 -0
- package/dist/server/routes/ask.js +295 -0
- package/dist/server/routes/batch.d.ts +6 -0
- package/dist/server/routes/batch.js +493 -0
- package/dist/server/routes/cache-warm.d.ts +25 -0
- package/dist/server/routes/cache-warm.js +212 -0
- package/dist/server/routes/cli-usage.d.ts +6 -0
- package/dist/server/routes/cli-usage.js +127 -0
- package/dist/server/routes/compat.d.ts +23 -0
- package/dist/server/routes/compat.js +652 -0
- package/dist/server/routes/crawl.d.ts +13 -0
- package/dist/server/routes/crawl.js +287 -0
- package/dist/server/routes/deep-fetch.d.ts +8 -0
- package/dist/server/routes/deep-fetch.js +57 -0
- package/dist/server/routes/deep-research.d.ts +11 -0
- package/dist/server/routes/deep-research.js +232 -0
- package/dist/server/routes/demo.d.ts +24 -0
- package/dist/server/routes/demo.js +517 -0
- package/dist/server/routes/do.d.ts +8 -0
- package/dist/server/routes/do.js +72 -0
- package/dist/server/routes/extract.d.ts +14 -0
- package/dist/server/routes/extract.js +325 -0
- package/dist/server/routes/feed.d.ts +15 -0
- package/dist/server/routes/feed.js +311 -0
- package/dist/server/routes/fetch-queue.d.ts +13 -0
- package/dist/server/routes/fetch-queue.js +357 -0
- package/dist/server/routes/fetch.d.ts +7 -0
- package/dist/server/routes/fetch.js +1274 -0
- package/dist/server/routes/go.d.ts +14 -0
- package/dist/server/routes/go.js +81 -0
- package/dist/server/routes/health.d.ts +11 -0
- package/dist/server/routes/health.js +141 -0
- package/dist/server/routes/jobs.d.ts +7 -0
- package/dist/server/routes/jobs.js +574 -0
- package/dist/server/routes/map.d.ts +11 -0
- package/dist/server/routes/map.js +116 -0
- package/dist/server/routes/mcp.d.ts +14 -0
- package/dist/server/routes/mcp.js +197 -0
- package/dist/server/routes/metrics.d.ts +37 -0
- package/dist/server/routes/metrics.js +149 -0
- package/dist/server/routes/oauth.d.ts +9 -0
- package/dist/server/routes/oauth.js +396 -0
- package/dist/server/routes/playground.d.ts +17 -0
- package/dist/server/routes/playground.js +283 -0
- package/dist/server/routes/reader.d.ts +18 -0
- package/dist/server/routes/reader.js +192 -0
- package/dist/server/routes/research.d.ts +14 -0
- package/dist/server/routes/research.js +482 -0
- package/dist/server/routes/screenshot.d.ts +22 -0
- package/dist/server/routes/screenshot.js +820 -0
- package/dist/server/routes/search.d.ts +6 -0
- package/dist/server/routes/search.js +874 -0
- package/dist/server/routes/session.d.ts +17 -0
- package/dist/server/routes/session.js +548 -0
- package/dist/server/routes/share.d.ts +18 -0
- package/dist/server/routes/share.js +462 -0
- package/dist/server/routes/smart-search/handlers/cars.d.ts +2 -0
- package/dist/server/routes/smart-search/handlers/cars.js +102 -0
- package/dist/server/routes/smart-search/handlers/flights.d.ts +2 -0
- package/dist/server/routes/smart-search/handlers/flights.js +72 -0
- package/dist/server/routes/smart-search/handlers/general.d.ts +13 -0
- package/dist/server/routes/smart-search/handlers/general.js +717 -0
- package/dist/server/routes/smart-search/handlers/hotels.d.ts +2 -0
- package/dist/server/routes/smart-search/handlers/hotels.js +88 -0
- package/dist/server/routes/smart-search/handlers/products.d.ts +2 -0
- package/dist/server/routes/smart-search/handlers/products.js +1309 -0
- package/dist/server/routes/smart-search/handlers/rental.d.ts +2 -0
- package/dist/server/routes/smart-search/handlers/rental.js +154 -0
- package/dist/server/routes/smart-search/handlers/restaurants.d.ts +2 -0
- package/dist/server/routes/smart-search/handlers/restaurants.js +225 -0
- package/dist/server/routes/smart-search/handlers/transit-verdict.d.ts +41 -0
- package/dist/server/routes/smart-search/handlers/transit-verdict.js +224 -0
- package/dist/server/routes/smart-search/index.d.ts +19 -0
- package/dist/server/routes/smart-search/index.js +546 -0
- package/dist/server/routes/smart-search/intent.d.ts +3 -0
- package/dist/server/routes/smart-search/intent.js +264 -0
- package/dist/server/routes/smart-search/llm.d.ts +16 -0
- package/dist/server/routes/smart-search/llm.js +70 -0
- package/dist/server/routes/smart-search/sources/reddit.d.ts +18 -0
- package/dist/server/routes/smart-search/sources/reddit.js +34 -0
- package/dist/server/routes/smart-search/sources/yelp.d.ts +25 -0
- package/dist/server/routes/smart-search/sources/yelp.js +171 -0
- package/dist/server/routes/smart-search/sources/youtube.d.ts +8 -0
- package/dist/server/routes/smart-search/sources/youtube.js +9 -0
- package/dist/server/routes/smart-search/types.d.ts +81 -0
- package/dist/server/routes/smart-search/types.js +1 -0
- package/dist/server/routes/smart-search/utils.d.ts +20 -0
- package/dist/server/routes/smart-search/utils.js +146 -0
- package/dist/server/routes/stats.d.ts +6 -0
- package/dist/server/routes/stats.js +71 -0
- package/dist/server/routes/stripe.d.ts +15 -0
- package/dist/server/routes/stripe.js +296 -0
- package/dist/server/routes/transcript-export.d.ts +10 -0
- package/dist/server/routes/transcript-export.js +178 -0
- package/dist/server/routes/usage.d.ts +9 -0
- package/dist/server/routes/usage.js +279 -0
- package/dist/server/routes/users.d.ts +8 -0
- package/dist/server/routes/users.js +1867 -0
- package/dist/server/routes/watch.d.ts +15 -0
- package/dist/server/routes/watch.js +309 -0
- package/dist/server/routes/webhooks.d.ts +26 -0
- package/dist/server/routes/webhooks.js +170 -0
- package/dist/server/routes/youtube.d.ts +6 -0
- package/dist/server/routes/youtube.js +130 -0
- package/dist/server/sentry.d.ts +14 -0
- package/dist/server/sentry.js +104 -0
- package/dist/server/types.d.ts +15 -0
- package/dist/server/types.js +7 -0
- package/dist/server/utils/response.d.ts +44 -0
- package/dist/server/utils/response.js +69 -0
- package/dist/server/utils/sse.d.ts +22 -0
- package/dist/server/utils/sse.js +38 -0
- package/dist/types.d.ts +552 -0
- package/dist/types.js +39 -0
- package/llms.txt +105 -0
- package/package.json +189 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Authentication & Usage Tracking
|
|
3
|
+
*
|
|
4
|
+
* Handles:
|
|
5
|
+
* - Anonymous usage (25 free fetches)
|
|
6
|
+
* - API key authentication
|
|
7
|
+
* - Usage checking against API
|
|
8
|
+
* - Config file management (~/.webpeel/config.json)
|
|
9
|
+
*/
|
|
10
|
+
interface CLIConfig {
|
|
11
|
+
apiKey?: string;
|
|
12
|
+
/** BYOK key for Brave Search (optional) */
|
|
13
|
+
braveApiKey?: string;
|
|
14
|
+
anonymousUsage: number;
|
|
15
|
+
lastReset: string;
|
|
16
|
+
planTier?: string;
|
|
17
|
+
planCachedAt?: string;
|
|
18
|
+
/** LLM settings for AI-powered features (extract, summarize, agent) */
|
|
19
|
+
llm?: {
|
|
20
|
+
apiKey?: string;
|
|
21
|
+
model?: string;
|
|
22
|
+
baseUrl?: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
interface UsageCheckResult {
|
|
26
|
+
allowed: boolean;
|
|
27
|
+
message?: string;
|
|
28
|
+
isAnonymous?: boolean;
|
|
29
|
+
usageInfo?: {
|
|
30
|
+
used: number;
|
|
31
|
+
limit: number;
|
|
32
|
+
remaining: number;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Load config from ~/.webpeel/config.json
|
|
37
|
+
*/
|
|
38
|
+
export declare function loadConfig(): CLIConfig;
|
|
39
|
+
/**
|
|
40
|
+
* Save config to ~/.webpeel/config.json
|
|
41
|
+
*/
|
|
42
|
+
export declare function saveConfig(config: CLIConfig): void;
|
|
43
|
+
/**
|
|
44
|
+
* Delete config file
|
|
45
|
+
*/
|
|
46
|
+
export declare function deleteConfig(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Check usage quota before making a request
|
|
49
|
+
*/
|
|
50
|
+
export declare function checkUsage(): Promise<UsageCheckResult>;
|
|
51
|
+
/**
|
|
52
|
+
* Show usage footer after successful fetch (for free/anonymous users only)
|
|
53
|
+
*/
|
|
54
|
+
export declare function showUsageFooter(usageInfo: {
|
|
55
|
+
used: number;
|
|
56
|
+
limit: number;
|
|
57
|
+
remaining: number;
|
|
58
|
+
} | undefined, isAnonymous: boolean, stealth?: boolean): void;
|
|
59
|
+
/**
|
|
60
|
+
* Prompt user for API key via stdin
|
|
61
|
+
*/
|
|
62
|
+
export declare function promptForApiKey(): Promise<string>;
|
|
63
|
+
/**
|
|
64
|
+
* Login command - save API key to config
|
|
65
|
+
*/
|
|
66
|
+
export declare function handleLogin(): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Logout command - remove API key from config
|
|
69
|
+
*/
|
|
70
|
+
export declare function handleLogout(): void;
|
|
71
|
+
/**
|
|
72
|
+
* Usage command - show current quota
|
|
73
|
+
*/
|
|
74
|
+
export declare function handleUsage(): Promise<void>;
|
|
75
|
+
export {};
|
package/dist/cli-auth.js
ADDED
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Authentication & Usage Tracking
|
|
3
|
+
*
|
|
4
|
+
* Handles:
|
|
5
|
+
* - Anonymous usage (25 free fetches)
|
|
6
|
+
* - API key authentication
|
|
7
|
+
* - Usage checking against API
|
|
8
|
+
* - Config file management (~/.webpeel/config.json)
|
|
9
|
+
*/
|
|
10
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync, unlinkSync } from 'fs';
|
|
11
|
+
import { homedir } from 'os';
|
|
12
|
+
import { join } from 'path';
|
|
13
|
+
import * as readline from 'readline';
|
|
14
|
+
// Config file location: ~/.webpeel/config.json
|
|
15
|
+
const CONFIG_DIR = join(homedir(), '.webpeel');
|
|
16
|
+
const CONFIG_FILE = join(CONFIG_DIR, 'config.json');
|
|
17
|
+
// API base URL (configurable via env var)
|
|
18
|
+
const API_BASE_URL = process.env.WEBPEEL_API_URL || 'https://api.webpeel.dev';
|
|
19
|
+
/**
|
|
20
|
+
* Load config from ~/.webpeel/config.json
|
|
21
|
+
*/
|
|
22
|
+
export function loadConfig() {
|
|
23
|
+
try {
|
|
24
|
+
if (!existsSync(CONFIG_FILE)) {
|
|
25
|
+
return {
|
|
26
|
+
anonymousUsage: 0,
|
|
27
|
+
lastReset: getLastMonday().toISOString(),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const content = readFileSync(CONFIG_FILE, 'utf-8');
|
|
31
|
+
const config = JSON.parse(content);
|
|
32
|
+
// Ensure lastReset exists
|
|
33
|
+
if (!config.lastReset) {
|
|
34
|
+
config.lastReset = getLastMonday().toISOString();
|
|
35
|
+
}
|
|
36
|
+
return config;
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
// If config is corrupted, start fresh
|
|
40
|
+
return {
|
|
41
|
+
anonymousUsage: 0,
|
|
42
|
+
lastReset: getLastMonday().toISOString(),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Save config to ~/.webpeel/config.json
|
|
48
|
+
*/
|
|
49
|
+
export function saveConfig(config) {
|
|
50
|
+
try {
|
|
51
|
+
// Ensure directory exists
|
|
52
|
+
if (!existsSync(CONFIG_DIR)) {
|
|
53
|
+
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
54
|
+
}
|
|
55
|
+
writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), 'utf-8');
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
console.error(`Warning: Failed to save config: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Delete config file
|
|
63
|
+
*/
|
|
64
|
+
export function deleteConfig() {
|
|
65
|
+
try {
|
|
66
|
+
if (existsSync(CONFIG_FILE)) {
|
|
67
|
+
unlinkSync(CONFIG_FILE);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
console.error(`Warning: Failed to delete config: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get the last Monday 00:00 UTC (start of current week)
|
|
76
|
+
*/
|
|
77
|
+
function getLastMonday() {
|
|
78
|
+
const now = new Date();
|
|
79
|
+
const day = now.getUTCDay();
|
|
80
|
+
const diff = day === 0 ? 6 : day - 1; // Days since last Monday
|
|
81
|
+
const lastMonday = new Date(now);
|
|
82
|
+
lastMonday.setUTCDate(now.getUTCDate() - diff);
|
|
83
|
+
lastMonday.setUTCHours(0, 0, 0, 0);
|
|
84
|
+
return lastMonday;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Check if anonymous usage counter needs to be reset (weekly reset)
|
|
88
|
+
*/
|
|
89
|
+
function shouldResetAnonymousUsage(config) {
|
|
90
|
+
const lastReset = new Date(config.lastReset);
|
|
91
|
+
const currentWeekStart = getLastMonday();
|
|
92
|
+
return lastReset < currentWeekStart;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Check usage quota before making a request
|
|
96
|
+
*/
|
|
97
|
+
export async function checkUsage() {
|
|
98
|
+
const config = loadConfig();
|
|
99
|
+
// Support WEBPEEL_API_KEY env var (e.g. for CI, admin use, non-interactive)
|
|
100
|
+
const envApiKey = process.env.WEBPEEL_API_KEY;
|
|
101
|
+
if (envApiKey && !config.apiKey) {
|
|
102
|
+
config.apiKey = envApiKey;
|
|
103
|
+
}
|
|
104
|
+
// Check if anonymous usage needs reset
|
|
105
|
+
if (shouldResetAnonymousUsage(config)) {
|
|
106
|
+
config.anonymousUsage = 0;
|
|
107
|
+
config.lastReset = getLastMonday().toISOString();
|
|
108
|
+
saveConfig(config);
|
|
109
|
+
}
|
|
110
|
+
// Anonymous user - allow first 25 fetches
|
|
111
|
+
if (!config.apiKey) {
|
|
112
|
+
const limit = 25;
|
|
113
|
+
const used = config.anonymousUsage;
|
|
114
|
+
const remaining = limit - used;
|
|
115
|
+
if (used >= limit) {
|
|
116
|
+
return {
|
|
117
|
+
allowed: false,
|
|
118
|
+
message: `You've used your ${limit} free fetches this week.\n\n` +
|
|
119
|
+
`📦 Sign up free → 500 fetches/week: webpeel login\n` +
|
|
120
|
+
`⚡ Pro ($9/mo) → 1,250 fetches/week: https://webpeel.dev/pricing\n` +
|
|
121
|
+
`🚀 Max ($29/mo) → 6,250 fetches/week\n`,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
// Increment usage counter
|
|
125
|
+
config.anonymousUsage++;
|
|
126
|
+
saveConfig(config);
|
|
127
|
+
return {
|
|
128
|
+
allowed: true,
|
|
129
|
+
isAnonymous: true,
|
|
130
|
+
usageInfo: {
|
|
131
|
+
used: used + 1,
|
|
132
|
+
limit,
|
|
133
|
+
remaining: remaining - 1,
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
// Authenticated user - check with API
|
|
138
|
+
try {
|
|
139
|
+
const response = await fetch(`${API_BASE_URL}/v1/cli/usage`, {
|
|
140
|
+
headers: {
|
|
141
|
+
'Authorization': `Bearer ${config.apiKey}`,
|
|
142
|
+
},
|
|
143
|
+
signal: AbortSignal.timeout(5000),
|
|
144
|
+
});
|
|
145
|
+
if (!response.ok) {
|
|
146
|
+
if (response.status === 401) {
|
|
147
|
+
return {
|
|
148
|
+
allowed: false,
|
|
149
|
+
message: `Authentication failed. Your API key may be invalid.\n\nRun: webpeel logout\nThen: webpeel login\n`,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
// If API returns other errors, allow gracefully
|
|
153
|
+
return { allowed: true };
|
|
154
|
+
}
|
|
155
|
+
const data = await response.json();
|
|
156
|
+
// Check burst limit
|
|
157
|
+
if (data.burst.used >= data.burst.limit) {
|
|
158
|
+
return {
|
|
159
|
+
allowed: false,
|
|
160
|
+
message: `Burst limit reached (${data.burst.used}/${data.burst.limit}). Resets in ${data.burst.resetsIn}.\nUpgrade: ${data.upgradeUrl}`,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
// Quick canFetch check from API
|
|
164
|
+
if (!data.canFetch) {
|
|
165
|
+
return {
|
|
166
|
+
allowed: false,
|
|
167
|
+
message: `Weekly limit reached (${data.weekly.used}/${data.weekly.limit}).\nResets: ${data.weekly.resetsAt}\nUpgrade: ${data.upgradeUrl}`,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
// Cache plan tier for offline feature gating
|
|
171
|
+
const planName = (data.plan?.tier || 'free').toLowerCase();
|
|
172
|
+
config.planTier = planName;
|
|
173
|
+
config.planCachedAt = new Date().toISOString();
|
|
174
|
+
saveConfig(config);
|
|
175
|
+
return {
|
|
176
|
+
allowed: true,
|
|
177
|
+
isAnonymous: false,
|
|
178
|
+
usageInfo: {
|
|
179
|
+
used: data.weekly.used,
|
|
180
|
+
limit: data.weekly.limit,
|
|
181
|
+
remaining: data.weekly.remaining,
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
// If API is unreachable, allow the request (graceful degradation)
|
|
187
|
+
return { allowed: true };
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Show usage footer after successful fetch (for free/anonymous users only)
|
|
192
|
+
*/
|
|
193
|
+
export function showUsageFooter(usageInfo, isAnonymous, stealth = false) {
|
|
194
|
+
if (!usageInfo)
|
|
195
|
+
return;
|
|
196
|
+
// Only show footer for anonymous or free users
|
|
197
|
+
if (isAnonymous) {
|
|
198
|
+
const costText = stealth ? ' (costs 5 credits)' : '';
|
|
199
|
+
console.error(`⚡ ${usageInfo.remaining}/${usageInfo.limit} free fetches remaining${costText} · webpeel login for 500/week free · webpeel.dev/pricing for unlimited`);
|
|
200
|
+
}
|
|
201
|
+
else if (usageInfo.limit <= 500) {
|
|
202
|
+
// Free tier authenticated users — show upgrade CTA
|
|
203
|
+
const costText = stealth ? ' (costs 5 credits)' : '';
|
|
204
|
+
const pct = Math.round((usageInfo.used / usageInfo.limit) * 100);
|
|
205
|
+
if (pct >= 80) {
|
|
206
|
+
console.error(`⚠️ ${usageInfo.remaining}/${usageInfo.limit} fetches remaining this week${costText}.`);
|
|
207
|
+
console.error(` Upgrade to Pro ($9/mo) for 1,250/week → webpeel.dev/pricing`);
|
|
208
|
+
}
|
|
209
|
+
else if (pct >= 50) {
|
|
210
|
+
console.error(`⚡ ${usageInfo.remaining}/${usageInfo.limit} fetches remaining this week${costText}. Upgrade: webpeel.dev/pricing`);
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
console.error(`⚡ ${usageInfo.remaining}/${usageInfo.limit} fetches remaining this week${costText}.`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
// Don't show footer for paid users
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Prompt user for API key via stdin
|
|
220
|
+
*/
|
|
221
|
+
export async function promptForApiKey() {
|
|
222
|
+
const rl = readline.createInterface({
|
|
223
|
+
input: process.stdin,
|
|
224
|
+
output: process.stdout,
|
|
225
|
+
});
|
|
226
|
+
return new Promise((resolve) => {
|
|
227
|
+
rl.question('Enter your API key (get one at https://app.webpeel.dev/keys): ', (answer) => {
|
|
228
|
+
rl.close();
|
|
229
|
+
resolve(answer.trim());
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Login command - save API key to config
|
|
235
|
+
*/
|
|
236
|
+
export async function handleLogin() {
|
|
237
|
+
const config = loadConfig();
|
|
238
|
+
if (config.apiKey) {
|
|
239
|
+
console.log('You are already logged in.');
|
|
240
|
+
console.log('Run `webpeel logout` first if you want to use a different API key.');
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
console.log('\n🔑 WebPeel CLI Authentication');
|
|
244
|
+
console.log('==============================\n');
|
|
245
|
+
console.log('Get your API key at: https://app.webpeel.dev/keys\n');
|
|
246
|
+
const apiKey = await promptForApiKey();
|
|
247
|
+
if (!apiKey) {
|
|
248
|
+
console.error('Error: API key cannot be empty');
|
|
249
|
+
process.exit(1);
|
|
250
|
+
}
|
|
251
|
+
// Validate API key format (should start with wp_)
|
|
252
|
+
if (!apiKey.startsWith('wp_')) {
|
|
253
|
+
console.error('Warning: API key should start with "wp_". Make sure you entered it correctly.');
|
|
254
|
+
}
|
|
255
|
+
// Validate API key against server before saving
|
|
256
|
+
console.log('\nVerifying API key...');
|
|
257
|
+
try {
|
|
258
|
+
const response = await fetch(`${API_BASE_URL}/v1/cli/usage`, {
|
|
259
|
+
headers: { 'Authorization': `Bearer ${apiKey}` },
|
|
260
|
+
signal: AbortSignal.timeout(5000),
|
|
261
|
+
});
|
|
262
|
+
if (response.ok) {
|
|
263
|
+
const data = await response.json();
|
|
264
|
+
const tierLabel = data.plan.tier.charAt(0).toUpperCase() + data.plan.tier.slice(1);
|
|
265
|
+
// Save to config with plan info
|
|
266
|
+
config.apiKey = apiKey;
|
|
267
|
+
config.planTier = data.plan.tier;
|
|
268
|
+
config.planCachedAt = new Date().toISOString();
|
|
269
|
+
saveConfig(config);
|
|
270
|
+
console.log(`\n✅ Successfully logged in!`);
|
|
271
|
+
console.log(`Plan: ${tierLabel} (${data.weekly.limit} fetches/week)`);
|
|
272
|
+
console.log(`Usage this week: ${data.weekly.used}/${data.weekly.limit}`);
|
|
273
|
+
}
|
|
274
|
+
else if (response.status === 401) {
|
|
275
|
+
console.error('\n❌ Invalid API key. Please check and try again.');
|
|
276
|
+
console.error('Get your API key at https://app.webpeel.dev/keys');
|
|
277
|
+
process.exit(1);
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
// Server returned non-401 error — save key anyway (might be temporary)
|
|
281
|
+
config.apiKey = apiKey;
|
|
282
|
+
saveConfig(config);
|
|
283
|
+
console.log('\n✓ API key saved (could not verify — server may be temporarily unavailable).');
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
catch {
|
|
287
|
+
// Network error — save key anyway (graceful)
|
|
288
|
+
config.apiKey = apiKey;
|
|
289
|
+
saveConfig(config);
|
|
290
|
+
console.log('\n✓ API key saved (could not reach server to verify).');
|
|
291
|
+
}
|
|
292
|
+
console.log('Run `webpeel usage` to check your quota.');
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Logout command - remove API key from config
|
|
296
|
+
*/
|
|
297
|
+
export function handleLogout() {
|
|
298
|
+
const config = loadConfig();
|
|
299
|
+
if (!config.apiKey) {
|
|
300
|
+
console.log('You are not logged in.');
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
deleteConfig();
|
|
304
|
+
console.log('✓ Logged out successfully');
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Usage command - show current quota
|
|
308
|
+
*/
|
|
309
|
+
export async function handleUsage() {
|
|
310
|
+
const config = loadConfig();
|
|
311
|
+
// Check for weekly reset
|
|
312
|
+
if (shouldResetAnonymousUsage(config)) {
|
|
313
|
+
config.anonymousUsage = 0;
|
|
314
|
+
config.lastReset = getLastMonday().toISOString();
|
|
315
|
+
saveConfig(config);
|
|
316
|
+
}
|
|
317
|
+
// Anonymous user
|
|
318
|
+
if (!config.apiKey) {
|
|
319
|
+
const limit = 25;
|
|
320
|
+
const used = config.anonymousUsage;
|
|
321
|
+
const remaining = limit - used;
|
|
322
|
+
const nextMonday = new Date(getLastMonday());
|
|
323
|
+
nextMonday.setUTCDate(nextMonday.getUTCDate() + 7);
|
|
324
|
+
console.log('\nWebPeel Usage (Anonymous)');
|
|
325
|
+
console.log('=========================\n');
|
|
326
|
+
console.log(`Plan: Anonymous (25 free fetches/week)`);
|
|
327
|
+
console.log(`Used this week: ${used}/${limit}`);
|
|
328
|
+
console.log(`Remaining: ${remaining}`);
|
|
329
|
+
console.log(`Resets: ${nextMonday.toUTCString()}`);
|
|
330
|
+
console.log('\n💡 Run `webpeel login` to get 500 fetches/week for free!');
|
|
331
|
+
console.log(' Or sign up at https://app.webpeel.dev/signup\n');
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
// Authenticated user - fetch from API
|
|
335
|
+
try {
|
|
336
|
+
const response = await fetch(`${API_BASE_URL}/v1/cli/usage`, {
|
|
337
|
+
headers: {
|
|
338
|
+
'Authorization': `Bearer ${config.apiKey}`,
|
|
339
|
+
},
|
|
340
|
+
signal: AbortSignal.timeout(5000),
|
|
341
|
+
});
|
|
342
|
+
if (!response.ok) {
|
|
343
|
+
if (response.status === 401) {
|
|
344
|
+
console.error('Error: Authentication failed. Your API key may be invalid.');
|
|
345
|
+
console.error('Run `webpeel logout` and `webpeel login` to re-authenticate.');
|
|
346
|
+
process.exit(1);
|
|
347
|
+
}
|
|
348
|
+
throw new Error(`API returned status ${response.status}`);
|
|
349
|
+
}
|
|
350
|
+
const data = await response.json();
|
|
351
|
+
const tierLabel = data.plan.tier.charAt(0).toUpperCase() + data.plan.tier.slice(1);
|
|
352
|
+
console.log('\nWebPeel Usage');
|
|
353
|
+
console.log('=============\n');
|
|
354
|
+
console.log(`Plan: ${tierLabel} (${data.weekly.limit}/week)`);
|
|
355
|
+
console.log(`Used this week: ${data.weekly.used}/${data.weekly.limit} (${data.weekly.percentUsed}%)`);
|
|
356
|
+
console.log(`Remaining: ${data.weekly.remaining}`);
|
|
357
|
+
console.log(`Burst: ${data.burst.used}/${data.burst.limit} this hour (resets in ${data.burst.resetsIn})`);
|
|
358
|
+
console.log(`Weekly reset: ${new Date(data.weekly.resetsAt).toUTCString()}`);
|
|
359
|
+
if (data.weekly.remaining <= 10) {
|
|
360
|
+
console.log(`\n⚠️ Running low on credits. Upgrade at ${data.upgradeUrl}`);
|
|
361
|
+
}
|
|
362
|
+
console.log();
|
|
363
|
+
}
|
|
364
|
+
catch (error) {
|
|
365
|
+
console.error(`Error fetching usage data: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
366
|
+
console.error('The API may be temporarily unavailable. Try again later.');
|
|
367
|
+
process.exit(1);
|
|
368
|
+
}
|
|
369
|
+
}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* WebPeel CLI — Entry point
|
|
4
|
+
*
|
|
5
|
+
* Registers all command groups and starts the Commander program.
|
|
6
|
+
* The heavy implementation lives in src/cli/commands/*.ts
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* npx webpeel <url> - Fetch and convert to markdown
|
|
10
|
+
* npx webpeel <url> --json - Output as JSON
|
|
11
|
+
* npx webpeel <url> --render - Force browser mode
|
|
12
|
+
* npx webpeel search "query" - DuckDuckGo search
|
|
13
|
+
* npx webpeel mcp - Start MCP server
|
|
14
|
+
* npx webpeel --help - Condensed help
|
|
15
|
+
* npx webpeel --help-all - Full option reference
|
|
16
|
+
*/
|
|
17
|
+
export {};
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* WebPeel CLI — Entry point
|
|
4
|
+
*
|
|
5
|
+
* Registers all command groups and starts the Commander program.
|
|
6
|
+
* The heavy implementation lives in src/cli/commands/*.ts
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* npx webpeel <url> - Fetch and convert to markdown
|
|
10
|
+
* npx webpeel <url> --json - Output as JSON
|
|
11
|
+
* npx webpeel <url> --render - Force browser mode
|
|
12
|
+
* npx webpeel search "query" - DuckDuckGo search
|
|
13
|
+
* npx webpeel mcp - Start MCP server
|
|
14
|
+
* npx webpeel --help - Condensed help
|
|
15
|
+
* npx webpeel --help-all - Full option reference
|
|
16
|
+
*/
|
|
17
|
+
// ── Auto-load .env from cwd (lightweight, no dotenv dependency) ──────────────
|
|
18
|
+
// Must happen BEFORE any imports that read env vars (e.g., WEBPEEL_API_KEY)
|
|
19
|
+
import { readFileSync, existsSync } from 'fs';
|
|
20
|
+
import { resolve } from 'path';
|
|
21
|
+
{
|
|
22
|
+
const envPath = resolve(process.cwd(), '.env');
|
|
23
|
+
if (existsSync(envPath)) {
|
|
24
|
+
for (const line of readFileSync(envPath, 'utf-8').split('\n')) {
|
|
25
|
+
const m = line.match(/^([A-Z_][A-Z0-9_]*)=(.*)$/);
|
|
26
|
+
if (m && !process.env[m[1]])
|
|
27
|
+
process.env[m[1]] = m[2].replace(/^["']|["']$/g, '');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
import { Command } from 'commander';
|
|
32
|
+
import { VERB_ALIASES, cliVersion, checkForUpdates, buildCommanderHelp, buildCondensedHelp, } from './cli/utils.js';
|
|
33
|
+
import { registerFetchCommands } from './cli/commands/fetch.js';
|
|
34
|
+
import { registerSearchCommands } from './cli/commands/search.js';
|
|
35
|
+
import { registerInteractCommands } from './cli/commands/interact.js';
|
|
36
|
+
import { registerAuthCommands } from './cli/commands/auth.js';
|
|
37
|
+
import { registerScreenshotCommands } from './cli/commands/screenshot.js';
|
|
38
|
+
import { registerJobsCommands } from './cli/commands/jobs.js';
|
|
39
|
+
import { registerMonitorCommands } from './cli/commands/monitor.js';
|
|
40
|
+
import { registerGuideCommand } from './cli/commands/guide.js';
|
|
41
|
+
import { registerDoctorCommand } from './cli/commands/doctor.js';
|
|
42
|
+
import { registerSetupCommand } from './cli/commands/setup.js';
|
|
43
|
+
import { registerSkillCommand } from './cli/commands/skill.js';
|
|
44
|
+
import { registerObserveCommand } from './cli/commands/observe.js';
|
|
45
|
+
// ── Early silent/log-level detection (must happen before any async module code) ──
|
|
46
|
+
// Set WEBPEEL_LOG_LEVEL early so logger checks see it when async IIFEs fire.
|
|
47
|
+
if (!process.env.WEBPEEL_LOG_LEVEL && process.argv.includes('--silent')) {
|
|
48
|
+
process.env.WEBPEEL_LOG_LEVEL = 'silent';
|
|
49
|
+
}
|
|
50
|
+
// ── Verb alias intercept (before Commander parses) ────────────────────────────
|
|
51
|
+
// "webpeel fetch <url>" → "webpeel <url>"
|
|
52
|
+
// Note: 'read' is intentionally excluded — it's a registered subcommand.
|
|
53
|
+
if (process.argv.length >= 3 && VERB_ALIASES.has(process.argv[2]?.toLowerCase())) {
|
|
54
|
+
process.argv.splice(2, 1);
|
|
55
|
+
}
|
|
56
|
+
// ── --help-all detection (must happen before Commander parses) ────────────────
|
|
57
|
+
const isHelpAll = process.argv.slice(2).some(a => a === '--help-all');
|
|
58
|
+
if (isHelpAll) {
|
|
59
|
+
const idx = process.argv.indexOf('--help-all');
|
|
60
|
+
if (idx !== -1)
|
|
61
|
+
process.argv[idx] = '--help';
|
|
62
|
+
}
|
|
63
|
+
// ── Program setup ─────────────────────────────────────────────────────────────
|
|
64
|
+
const program = new Command();
|
|
65
|
+
program
|
|
66
|
+
.name('webpeel')
|
|
67
|
+
.description('Fast web fetcher for AI agents')
|
|
68
|
+
.version(cliVersion)
|
|
69
|
+
.enablePositionalOptions();
|
|
70
|
+
// ── Help formatting ───────────────────────────────────────────────────────────
|
|
71
|
+
program.configureHelp({
|
|
72
|
+
sortSubcommands: true,
|
|
73
|
+
showGlobalOptions: false,
|
|
74
|
+
formatHelp: (cmd, helper) => {
|
|
75
|
+
if (cmd.parent !== null || isHelpAll) {
|
|
76
|
+
return buildCommanderHelp(cmd, helper);
|
|
77
|
+
}
|
|
78
|
+
return buildCondensedHelp();
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
// ── Update check (non-blocking, background) ───────────────────────────────────
|
|
82
|
+
void checkForUpdates();
|
|
83
|
+
// ── Register all command groups ───────────────────────────────────────────────
|
|
84
|
+
// Doctor, setup, and other subcommands must register BEFORE fetch,
|
|
85
|
+
// because fetch registers a catch-all `[url]` default argument.
|
|
86
|
+
registerDoctorCommand(program);
|
|
87
|
+
registerSetupCommand(program);
|
|
88
|
+
registerSkillCommand(program);
|
|
89
|
+
registerSearchCommands(program);
|
|
90
|
+
registerInteractCommands(program);
|
|
91
|
+
registerAuthCommands(program);
|
|
92
|
+
registerScreenshotCommands(program);
|
|
93
|
+
registerJobsCommands(program);
|
|
94
|
+
registerMonitorCommands(program);
|
|
95
|
+
registerObserveCommand(program);
|
|
96
|
+
registerGuideCommand(program);
|
|
97
|
+
registerFetchCommands(program);
|
|
98
|
+
// ── Parse ─────────────────────────────────────────────────────────────────────
|
|
99
|
+
program.parse();
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Page actions executor for browser automation
|
|
3
|
+
*
|
|
4
|
+
* This is WebPeel's "Actions API" — click/scroll/type/wait before extracting.
|
|
5
|
+
*
|
|
6
|
+
* Timeouts:
|
|
7
|
+
* - Default per action: 5s
|
|
8
|
+
* - Max total across all actions: 30s
|
|
9
|
+
*/
|
|
10
|
+
import type { Page } from 'playwright';
|
|
11
|
+
import type { PageAction } from '../types.js';
|
|
12
|
+
export declare const DEFAULT_ACTION_TIMEOUT_MS = 5000;
|
|
13
|
+
export declare const MAX_TOTAL_ACTIONS_MS = 30000;
|
|
14
|
+
export interface AutoScrollOptions {
|
|
15
|
+
/** Maximum number of scroll iterations (default: 20) */
|
|
16
|
+
maxScrolls?: number;
|
|
17
|
+
/** Milliseconds to wait between scrolls (default: 1000) */
|
|
18
|
+
scrollDelay?: number;
|
|
19
|
+
/** Total timeout in milliseconds (default: 30000) */
|
|
20
|
+
timeout?: number;
|
|
21
|
+
/** Optional: wait for this CSS selector after each scroll */
|
|
22
|
+
waitForSelector?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface AutoScrollResult {
|
|
25
|
+
/** Number of scroll iterations performed */
|
|
26
|
+
scrollCount: number;
|
|
27
|
+
/** Final document height in pixels */
|
|
28
|
+
finalHeight: number;
|
|
29
|
+
/** Whether the page content grew during scrolling */
|
|
30
|
+
contentGrew: boolean;
|
|
31
|
+
/** Whether a virtual/inner scrollable container was found and used */
|
|
32
|
+
scrollContainerFound?: boolean;
|
|
33
|
+
/** Total number of DOM mutations detected during scrolling */
|
|
34
|
+
mutationsDetected?: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Normalize a raw actions array to WebPeel's internal PageAction shape.
|
|
38
|
+
* Accepts Firecrawl-style fields (milliseconds, text, direction/amount).
|
|
39
|
+
*/
|
|
40
|
+
export declare function normalizeActions(input?: unknown): PageAction[] | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Detect the most likely scrollable container on the page.
|
|
43
|
+
* Returns a CSS selector string for the container, or null if only window scrolling is needed.
|
|
44
|
+
*
|
|
45
|
+
* Looks for elements with overflow-y: auto|scroll whose scrollHeight > clientHeight,
|
|
46
|
+
* preferring the largest such element. Used by autoScroll and scrollThrough.
|
|
47
|
+
*/
|
|
48
|
+
export declare function detectScrollContainer(page: Page): Promise<string | null>;
|
|
49
|
+
/**
|
|
50
|
+
* Intelligently scroll the page to load all lazy/infinite-scroll content.
|
|
51
|
+
*
|
|
52
|
+
* Improvements over the basic version:
|
|
53
|
+
* 1. Detects virtual/inner scroll containers (Polymarket, React virtualized lists)
|
|
54
|
+
* 2. Uses MutationObserver to detect DOM additions (not just height changes)
|
|
55
|
+
* 3. Gracefully handles execution context destruction (SPA navigation)
|
|
56
|
+
* 4. Stability requires BOTH no height change AND no DOM mutations
|
|
57
|
+
*
|
|
58
|
+
* Stops when:
|
|
59
|
+
* - Height is stable AND no DOM mutations for 2 consecutive checks
|
|
60
|
+
* - maxScrolls limit is reached
|
|
61
|
+
* - Total timeout is exceeded
|
|
62
|
+
* - Execution context is destroyed (SPA navigation)
|
|
63
|
+
*/
|
|
64
|
+
export declare function autoScroll(page: Page, options?: AutoScrollOptions): Promise<AutoScrollResult>;
|
|
65
|
+
export declare function executeActions(page: Page, actions: PageAction[], screenshotOptions?: {
|
|
66
|
+
fullPage?: boolean;
|
|
67
|
+
type?: 'png' | 'jpeg';
|
|
68
|
+
quality?: number;
|
|
69
|
+
}): Promise<Buffer | undefined>;
|