Skip to content

[SCR-383] Auto-Mode (mode=auto) support#24

Open
kostas-jakeliunas-sb wants to merge 1 commit into
masterfrom
SCR-383/auto-mode-support
Open

[SCR-383] Auto-Mode (mode=auto) support#24
kostas-jakeliunas-sb wants to merge 1 commit into
masterfrom
SCR-383/auto-mode-support

Conversation

@kostas-jakeliunas-sb

@kostas-jakeliunas-sb kostas-jakeliunas-sb commented Jun 30, 2026

Copy link
Copy Markdown

Merge order: part of the [SCR-383] Auto-Mode client rollout — merge once the server PR ScrapingBee/scrapingbee-API#1242 is merged + the flag is enabled.

tl;dr

Adds Auto-Mode (mode=auto) discoverability + docs to the Node SDK. The SDK is pass-through so the params already work on the wire today — this surfaces them for TypeScript autocomplete and documents the feature (including the under-documented spb-auto-cost response header). Version bumped 1.8.2 → 1.8.3, dist/ rebuilt and committed. 67 tests green.

Summary

  • src/index.ts — added mode?: 'auto' and max_cost?: number to the HtmlApiParams type. Pure additive: the type's index signature ({ [key: string]: any }) already permitted these params, so no runtime change — this is for autocomplete/discoverability, consistent with how all other known params are enumerated.
  • README.md — new "Auto-Mode" subsection in the HTML API section (after the GET example) with a htmlApi() GET example, a line showing how to read the credits charged via response.headers['spb-auto-cost'] (axios lowercases header keys — under-documented today), and caveats: GET only, max_cost optional (omit = uncapped), don't combine mode:'auto' with render_js/premium_proxy/stealth_proxy.
  • CHANGELOG.md — added a 1.8.3 entry.
  • package.json — version 1.8.2 → 1.8.3 (prebuild re-synced src/version.ts).
  • dist/rebuilt committed output via npm run build (dist/index.d.ts has the new type fields; dist/version.{js,d.ts} reflect 1.8.3). dist/ is committed in this repo, so it's included in the PR.

Note: incidental package-lock.json churn from npm install (npm adding "peer": true annotations) was reverted to keep the diff focused — no dependency changes in this PR.

Client contract (server already shipped, beta, flag-gated)

  • mode=auto: server tries cheap→expensive configs, stops at first success, charges only the winning config (0 credits if all fail).
  • max_cost (int ≥ 1, optional, requires mode=auto): caps the credits a request may cost; omit = uncapped.
  • Response header Spb-auto-cost = credits charged for the winning config.

Test plan

  • npm install
  • npm run buildprebuild syncs src/version.ts to 1.8.3, tsc compiles; dist/ updated and staged
  • npm test — 67 passing (mocha + axios-mock-adapter, mocked; no network)
  • Verified dist/index.d.ts contains mode?: 'auto' and max_cost?: number
  • Verified package.json + src/version.ts + dist/version.{js,d.ts} all at 1.8.3
  • Merge only after the server-side Auto-Mode feature is enabled in production

🤖 Generated with Claude Code

Adds discoverability + docs for the server-side Auto-Mode feature
(mode=auto): server picks the cheapest scraping config that succeeds,
charges only the winning config. The SDK is pass-through, so the params
already work on the wire; this surfaces them for autocomplete and docs.

- src/index.ts: add `mode?: 'auto'` and `max_cost?: number` to the
  HtmlApiParams type (index signature already permitted them; this is
  pure additive for autocomplete/discoverability).
- README.md: new "Auto-Mode" subsection in the HTML API section with a
  GET example and a note on reading the `spb-auto-cost` response header
  (axios lowercases header keys), plus GET-only / max_cost / param
  incompatibility caveats.
- CHANGELOG.md: 1.8.3 entry.
- package.json: 1.8.2 -> 1.8.3 (prebuild synced src/version.ts).
- dist/: rebuilt committed output (npm run build) for the new type + version.

Tests: 67 passing (mocha, mocked).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@kostas-jakeliunas-sb kostas-jakeliunas-sb marked this pull request as ready for review June 30, 2026 12:57
@kostas-jakeliunas-sb kostas-jakeliunas-sb changed the title [DRAFT — DO NOT MERGE] [SCR-383] Auto-Mode (mode=auto) support [SCR-383] Auto-Mode (mode=auto) support Jun 30, 2026
@kostas-jakeliunas-sb kostas-jakeliunas-sb self-assigned this Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants