Skip to content

add BrowserRun types#6771

Open
Refaerds wants to merge 1 commit into
cloudflare:mainfrom
Refaerds:maryna/browser-run
Open

add BrowserRun types#6771
Refaerds wants to merge 1 commit into
cloudflare:mainfrom
Refaerds:maryna/browser-run

Conversation

@Refaerds
Copy link
Copy Markdown

Summary

Adds TypeScript type definitions for the existing browser binding:

  • BrowserRun — abstract class with fetch() and overloaded quickAction() method supporting 8 action types
  • Action-specific option types: BrowserRunScreenshotOptions, BrowserRunPDFOptions, BrowserRunScrapeOptions, BrowserRunLinksOptions, BrowserRunSnapshotOptions, BrowserRunJsonOptions, BrowserRunMarkdownOptions, BrowserRunContentOptions
  • Quick action response types: BrowserRunContentSuccessResponse, BrowserRunLinksSuccessResponse, BrowserRunScrapeSuccessResponse, BrowserRunSnapshotSuccessResponse, BrowserRunJsonSuccessResponse, BrowserRunMarkdownSuccessResponse, BrowserRunErrorResponse, BrowserRunJsonErrorResponse

@Refaerds Refaerds requested review from a team as code owners May 19, 2026 11:19
@Refaerds Refaerds requested a review from jamesopstad May 19, 2026 11:19
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 19, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@Refaerds
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request May 19, 2026
Comment thread types/defines/browser-run.d.ts Outdated
@Refaerds Refaerds force-pushed the maryna/browser-run branch 2 times, most recently from 6490581 to a78db9a Compare May 20, 2026 07:33
@jamesopstad
Copy link
Copy Markdown
Contributor

/bonk review this PR

Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: BrowserRun types

Good addition overall — the types are well-documented with JSDoc, follow the BrowserRun product prefix convention correctly, and the overloaded quickAction pattern is a solid approach for discriminated-union-style APIs.

I have a few issues to flag, one of which is a type system anti-pattern explicitly called out in this repo's guidelines.

Summary of issues

  1. result: object is a repo anti-patterntypes/AGENTS.md says "Never use bare object as a type."
  2. BrowserRunJsonOptions union doesn't enforce the documented constraint — both prompt and response_format can be provided in either branch.
  3. cacheTTL placement@ruifigueira already flagged this; needs confirmation.
  4. generated-snapshot/ files should be regenerated, not hand-editedtypes/AGENTS.md states: "Do not edit files in generated-snapshot/ directly — they are overwritten by just generate-types." Please run just generate-types and commit the resulting files instead of manually editing the snapshots.
  5. Minor: inconsistent meta presence across response types (may be intentional, but worth confirming).
  6. Minor: fetch() method has no JSDoc.

Comment thread types/defines/browser-run.d.ts Outdated
Comment thread types/defines/browser-run.d.ts
Comment thread types/defines/browser-run.d.ts
Comment thread types/defines/browser-run.d.ts
Comment thread types/defines/browser-run.d.ts
@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented May 20, 2026

Review posted successfully. Here's a summary of what I flagged:

Review posted on PR #6771

6 issues identified, 5 inline comments:

  1. result: object anti-pattern (line 327) — types/AGENTS.md explicitly forbids bare object. Suggested Record<string, unknown> instead.

  2. BrowserRunJsonOptions union doesn't enforce exclusivity (lines 237-253) — The JSDoc says "exactly one of prompt or response_format" but the union allows both. Suggested using never on the excluded branch, or updating the doc if both are actually allowed.

  3. cacheTTL placement (line 119) — Flagged alignment with @ruifigueira's existing comment about whether cacheTTL was moved into options.

  4. generated-snapshot/ manually edited (top-level comment) — Per types/AGENTS.md, these files should be regenerated via just generate-types, not hand-edited.

  5. Inconsistent meta field (lines 273-277) — Some success responses have meta: BrowserRunResponseMeta (content, snapshot) while others don't (links, scrape, json, markdown). Requested confirmation this is intentional.

  6. Missing fetch() JSDoc (line 354) — Suggested adding a brief description to match other binding classes.

github run

@Refaerds Refaerds force-pushed the maryna/browser-run branch from a78db9a to 13f31f1 Compare May 20, 2026 08:25
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.

3 participants