@spider-cloud/pi-spider-tools

extensionmaintained

Pi extension that exposes Spider Cloud scraping, crawling, search, and browser automation tools.

by · v0.1.0 · published 1mo ago

$ pi install npm:@spider-cloud/pi-spider-tools
downloads/mo
65
stars
0
last push
1mo ago
open issues
0

Signals

license: MITtestspi manifest: missinginstall size: —deps: 0peer deps: 0

Download trend

168 downloads · last 12 weeks (weekly)

README

pi-spider-tools

Native Pi coding agent tools that expose Spider Cloud scraping, crawling, search, screenshot, and browser-automation capabilities.

It ships two tool sets, registered from separate entry files:

  • Core tier (src/spider.ts) — stateless tools that call the Spider Cloud REST API directly.
  • Browser tier (src/browser.ts) — stateful remote-browser automation backed by the spider-browser package (WebSocket to Spider's pre-warmed browser fleet).

Core tools

ToolEndpointDescription
spider_scrapePOST /scrapeScrape a single URL; faster/cheaper than crawling.
spider_crawlPOST /crawlCrawl a site following links up to a limit/depth.
spider_searchPOST /searchWeb search, optionally fetching each result's content.
spider_linksPOST /linksCollect links without returning page content.
spider_screenshotPOST /screenshotCapture a page screenshot (base64 PNG in the payload).
spider_unblockerPOST /unblockerFetch anti-bot-protected pages via the stealth unblocker.
spider_transformPOST /transformConvert raw HTML to markdown/text (no web request).
spider_get_creditsGET /data/creditsCheck remaining credit balance (free).

Browser tools

Stateful: spider_browser_open returns a session_id that the other tools take, and spider_browser_close releases it. Open sessions bill until closed — they auto-close after 5 minutes of inactivity and on pi shutdown/reload, and at most 5 may be open at once.

ToolDescription
spider_browser_openOpen a remote browser session; returns a session_id.
spider_browser_navigateNavigate the session to a URL and wait for load.
spider_browser_clickClick an element by CSS selector.
spider_browser_fillFill a form field by CSS selector.
spider_browser_screenshotCapture a screenshot (returned as an inline image).
spider_browser_contentGet the page HTML or visible text.
spider_browser_evaluateExecute JavaScript in the page and return the result.
spider_browser_wait_forWait for a selector, navigation, or network idle.
spider_browser_closeClose the session and stop billing.

Result display

Core tools cap processing to the first 10 results (the model is told when more were available, e.g. processed first 10 of 31 results) and render a compact summary in the TUI instead of dumping raw JSON — a one-line N results row that expands to a title — url list. The full (capped) JSON is still sent to the model.

Configuration

The extension reads SPIDER_API_KEY from the environment (pi does not load .env itself). Get a key at https://spider.cloud/api-keys. Optional overrides: SPIDER_API_URL (core REST base) and SPIDER_BROWSER_URL (browser fleet WebSocket).

Primary: pass the key inline

Prefix the command with the key — the simplest way to run a one-off (works whether the extension is installed or loaded with -e):

SPIDER_API_KEY=sk-... pi

Optional: auto-load with direnv

To avoid typing the key each time, keep it in a gitignored .env at the workspace root and let direnv load it whenever you enter the directory:

brew install direnv                          # once
echo 'eval "$(direnv hook zsh)"' >> ~/.zshrc # once (then open a new terminal)

echo 'SPIDER_API_KEY=sk-...' > .env          # gitignored
printf 'dotenv\n' > .envrc                    # loads .env
direnv allow

Pi started from this directory then sees the key automatically. (Or, always on: echo 'export SPIDER_API_KEY="sk-..."' >> ~/.zshrc.)

Install

# install from npm (registers both tiers from package.json)
pi install npm:@spider-cloud/pi-spider-tools
pi list

# or try it for a single session without installing
pi -e npm:@spider-cloud/pi-spider-tools

From a local clone (development)

# install by path (both tiers, from package.json)
pi install ./extensions/pi-spider-tools

# or load a single tier ad-hoc; /reload picks up edits
pi -e ./src/spider.ts          # core tools only
pi -e ./src/browser.ts         # browser tools only
pi -e ./src/spider.ts -e ./src/browser.ts   # both

Commands

/spider           open the menu
/spider status    show API key status and which core tools are enabled
/spider tools     interactively toggle which core Spider tools are active
/spider enable     enable all core Spider tools
/spider disable    disable all core Spider tools
/spider help      show help

/spider-browser status   show API key status and open browser sessions
/spider-browser close    close all open browser sessions
/spider-browser help     show browser help

Core tool selection is persisted to pi-spider-tools-settings.json in your Pi agent directory ($PI_CODING_AGENT_DIR, defaulting to ~/.pi/agent).

Development

npm install
npm run typecheck   # tsc --noEmit
npm run check       # biome + typecheck

See parameter details for each endpoint at https://spider.cloud/docs/api.

License

MIT