BOX-186: browser api - #202
Conversation
| export class Tab { | ||
| /** CDP target id of this tab. */ | ||
| readonly id: string; | ||
| /** Last known URL of this tab (from `tab.create`/`listTabs`; not live). */ | ||
| readonly url?: string; | ||
| /** Last known title of this tab (from `tab.create`/`listTabs`; not live). */ | ||
| readonly title?: string; | ||
|
|
There was a problem hiding this comment.
client.ts has too many things, no need to split everything but can we at least put the new classes in new files?
There was a problem hiding this comment.
agreed, but I think we should do this splitting comprehensively in a seperate pr
There was a problem hiding this comment.
Pull request overview
Adds a first-class box.browser API to the TypeScript SDK, enabling headless Chromium control (tab lifecycle, DOM content, screenshots, extraction/agent actions, and session recordings) plus supporting examples and tests.
Changes:
- Introduces
TabandBox.browserAPIs (tabs, screenshots, extract/observe/act/run, CDP/live-view URLs, recordings). - Extends SDK types/exports and
Box.createconfig withbrowser?: boolean. - Adds unit + integration tests and multiple runnable examples; includes a changeset entry.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-workspace.yaml | Workspace config updated to allow esbuild builds. |
| packages/sdk/src/types.ts | Adds browser-related public types and BoxConfig.browser. |
| packages/sdk/src/index.ts | Exports Tab and browser-related types from the public entrypoint. |
| packages/sdk/src/client.ts | Implements Tab, box.browser namespace, recordings helpers, screenshot decoding, and JSON-schema conversion logic. |
| packages/sdk/src/tests/integration/browser.integration.test.ts | Adds integration coverage for basic browser flows when API key is present. |
| packages/sdk/src/tests/helpers.test.ts | Updates/extends toJsonSchema tests for Zod 3 + Zod 4. |
| packages/sdk/src/tests/box-create.test.ts | Ensures browser: true is sent only when requested. |
| packages/sdk/src/tests/box-browser.test.ts | Adds comprehensive unit tests for tab operations, screenshots, schema extraction, agent actions, and recordings. |
| packages/sdk/examples/headless-browser.ts | New example demonstrating headless DOM ops + extraction + screenshots. |
| packages/sdk/examples/connect-test.ts | New minimal example for CDP URL retrieval. |
| packages/sdk/examples/browser.ts | New end-to-end example covering most of the Tab surface. |
| packages/sdk/examples/browser-screencast.ts | New example for tab.liveViewUrl() usage. |
| packages/sdk/examples/browser-recording-demo.ts | New example demonstrating recordings + a simple scripted flow. |
| packages/sdk/examples/browser-connect.ts | New example showing Playwright CDP connection flow. |
| .changeset/browser-api-polish.md | Patch changeset describing the new/updated browser features. |
Comments suppressed due to low confidence (1)
packages/sdk/src/client.ts:705
- This docstring says tab-scoped operations are limited to
goto/content/screenshot/extract/observe/close, but the API also exposesact,run, andliveViewUrlonTab. Updating the list will keep the public docs accurate.
* tabs. All page operations (`goto`, `content`, `screenshot`, `extract`,
* `observe`, `close`) live on the {@link Tab} handle returned here.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 35 out of 35 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
packages/sdk/src/client.ts:2
- Static import from
zod/v4/coremakes the SDK hard-require Zod v4 at module-load time. This conflicts withpackages/sdk/package.jsondeclaringzodas an optional peer (^3.25.0 || ^4.0.0): consumers with Zod v3 (or no Zod installed, if they don't use extract/run) will crash on import becausezod/v4/corecan't be resolved. Consider either (a) making the Zod v4 converter optional via lazy/dynamic import (so v3-only installs still work), or (b) tightening the peerDependency to^4/ adding a direct dependency if v4 is now required.
No description provided.