Commit Graph

198 Commits

Author SHA1 Message Date
Yanwu cbd4e12a6f Merge pull request #156 from epiral/release-please--branches--main--components--bb-browser
chore(main): release bb-browser 0.11.2
bb-browser-v0.11.2
2026-04-03 10:55:52 +08:00
github-actions[bot] 8f67c7bb2f chore(main): release bb-browser 0.11.2 2026-04-03 02:55:02 +00:00
Yanwu 67efdd38fd fix: CDP 503 returns diagnostics immediately instead of 30s timeout (#157)
When Chrome disconnects or CDP connection fails, the daemon now:
- Returns 503 immediately instead of waiting 30 seconds
- Includes CDP target address, failure reason, and remediation hint
- Stores lastError in CdpConnection for diagnostic context

Before: {"error":"CDP connection timeout"} after 30s wait
After:  {"error":"Chrome not connected (CDP at host:port)","reason":"...","hint":"..."} immediately

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 10:54:48 +08:00
Yanwu 1931c55841 fix: remove extension packaging from publish workflow (#155)
Extension was removed in 0.11.0. Also removes one-time release-as override.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 09:46:02 +08:00
Yanwu e7f1e5c4b4 Merge pull request #135 from epiral/release-please--branches--main--components--bb-browser
chore(main): release bb-browser 0.11.1
bb-browser-v0.11.1
2026-04-03 09:36:39 +08:00
github-actions[bot] 4b575e007f chore(main): release bb-browser 0.11.1 2026-04-03 01:24:15 +00:00
Yanwu 9435d677fc chore: force release as 0.11.1 (#154)
Breaking changes (Extension removal) were already shipped in 0.11.0.
This release is bug fixes only (daemon auto-launch Chrome).

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 09:23:24 +08:00
Yanwu e857cdd590 chore: configure release-please for pre-1.0 versioning (#153)
Add bump-minor-pre-major and bump-patch-for-minor-pre-major so
breaking changes bump minor (not major) while version is 0.x.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 09:18:56 +08:00
Yanwu 9243517f18 fix: auto-launch Chrome when daemon starts (#152)
* fix: auto-launch Chrome when daemon starts (#136, #143, #141)

CLI's ensureDaemon() now discovers/launches Chrome via cdp-discovery
before spawning the daemon, and passes --cdp-host/--cdp-port to it.
Previously the daemon was spawned with no CDP info, failed silently,
and users got "Daemon did not start in time" for every command.

- CLI: call discoverCdpPort() before spawn, pass CDP endpoint to daemon
- CLI: improve error messages with specific remediation steps
- CLI: increase startup timeout from 5s to 10s (Chrome launch time)
- MCP: read managed port file and pass --cdp-port to daemon
- Tests: 8 new daemon-startup tests reproducing and verifying the fix
- Tests: fix daemon-lifecycle tests (unique ports, tsx runner, proper cleanup)

Closes #136, closes #143, relates to #141, #118, #146

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: remove unused variable in MCP ensureDaemon

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test: fix daemon-lifecycle kill-9 assertion for parallel CI

Relax PID equality assertion since parallel test suites share
daemon.json in CI. Assert file existence and valid structure instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Revert "test: fix daemon-lifecycle kill-9 assertion for parallel CI"

This reverts commit ba572d0f2a.

* fix: isolate test suites with BB_BROWSER_HOME to avoid parallel conflicts

Daemon and CLI tests both spawn daemon processes that write to
~/.bb-browser/daemon.json. When turbo runs them in parallel, they
conflict. Fix by:
- Support BB_BROWSER_HOME env var in daemon and daemon-manager
- Each test suite uses its own temp dir via BB_BROWSER_HOME

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: use DAEMON_DIR for managed port file path in daemon

The managed port file path was hardcoded to ~/.bb-browser/browser/cdp-port
ignoring BB_BROWSER_HOME. This broke test isolation in CI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 09:15:08 +08:00
yan5xu 6d52b22601 fix: consolidate daemon state into daemon.json with PID liveness check
Replace separate PID file (/tmp/bb-browser.pid) and token file
(~/.bb-browser/daemon.token) with a single ~/.bb-browser/daemon.json
containing pid, host, port, and token.

CLI now reads daemon.json to connect, using the actual bound address
instead of hardcoded DAEMON_HOST. PID liveness check via process.kill(0)
detects stale daemon.json from crashed processes and auto-recovers.

Add harness tests for PID strategy and cold-start recovery scenario.

Closes #140

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 05:48:25 +08:00
yan5xu 7936566ec5 feat!: remove Chrome Extension package
Move buildDomTree.js to packages/shared/. Delete packages/extension/
entirely. Update path references in daemon and CLI. Remove
build:extension script and release-please manifest sync.

The daemon connects directly to Chrome via CDP WebSocket since v0.11.0.
The Extension is no longer needed.

BREAKING CHANGE: Chrome Extension is removed. Users who relied on the
extension-based flow should use the daemon-direct mode instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 05:33:17 +08:00
Xeon 37f8d64959 fix: align daemon host defaults and restore daemon command (#137) 2026-04-02 05:29:36 +08:00
yan5xu 98d656cc7f chore: sync release-please manifest to v0.11.0
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 16:08:29 +08:00
haibinwang9 208643638e feat(cli): support cdpUrl and cdpHost from OpenClaw (#70)
* feat(cli): support cdpUrl and cdpHost from OpenClaw

- Prioritize cdpUrl field for full CDP endpoint URL
- Fall back to cdpHost + cdpPort if cdpUrl not available
- cdpHost defaults to 127.0.0.1 when not specified

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(cli): increase openclaw timeout to 30s

* perf(cli): add env var and file cache for CDP discovery

---------

Co-authored-by: User <user@example.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-01 16:01:04 +08:00
yan5xu cbdd26c2c8 fix: update openclaw-bridge tests for new flag ordering (#102)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 16:00:48 +08:00
Trystan Lei 1b3a39437f fix(cli): place openclaw browser flags before subcommand (#102) 2026-04-01 15:59:41 +08:00
yan5xu ab43e2bfe4 fix: restore npm package name to bb-browser
@pinix/browser is the clip.json name, not the npm package name.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 15:52:41 +08:00
yan5xu 8ceed8c978 release: v0.11.0
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
v0.11.0
2026-04-01 15:49:20 +08:00
Yanwu fb1a9b0644 chore: add harness — tests, CI, protocol types, design invariants (#133)
* chore: add harness — tests, CI, protocol types, design invariants

Context layer:
- Rewrite AGENTS.md: new daemon architecture, 3-file command pattern,
  7 design invariants (INV-1 through INV-7), testing section
- Update protocol.ts: add tab/seq/cursor/since fields, update
  DaemonStatus, remove SSE types, widen TabInfo.tabId to string

Constraints layer:
- Unit tests: RingBuffer (14), TabState + TabStateManager (36)
- Contract tests: all 7 invariants verified (48)
- Protocol drift tests: real daemon HTTP response shape checks (13,
  skipped when Chrome unavailable)
- CI workflow: build + lint + test on push/PR to main
- Pre-commit hook: pnpm build && pnpm test via husky

GC layer:
- Harness scenarios doc: 6 reusable Agent workflow scenarios for
  periodic UX validation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: resolve lint errors caught by CI

- Remove unused imports (TabState, TabInfo, JsonObject, Response)
- Remove unused variable assignments in tests (r1-r4)
- Change `let items` to `const items` in command-dispatch
- Remove stale eslint-disable directive, use proper cast
- Exclude .d.ts files from eslint in daemon package

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: address Codex review findings

- cursor returns since threshold instead of 0 on empty results,
  preventing infinite re-fetch in incremental polling loops
- Guard shutdown against double-call (SIGINT + /shutdown race)
- Fix timer leak in discoverCdpPort when fetch fails

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* docs: update READMEs — remove Extension references, update architecture diagram

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 15:47:10 +08:00
Yanwu 62af1f89d7 refactor: unify daemon — CDP direct, remove Extension dependency (#132)
Merge daemon + cdp-monitor into a single CDP-direct backend. All CLI
and MCP commands now route through the daemon HTTP API instead of
direct CDP connections or Extension relay.

Key changes:
- Daemon: rewrite to hold persistent CDP WebSocket, handle all 30+
  commands via dispatchRequest, per-tab event state with RingBuffer,
  short tab IDs (4-char hex), global seq counter, incremental queries
  via since/cursor mechanism
- CLI: all commands route through daemon HTTP, --tab accepts string
  short IDs, add --since/--method/--status flags for network queries,
  fix tab close with --tab flag, fix invalid tab ID silent fallback
- MCP: tab parameter z.number() → z.string(), add browser_console
  and browser_errors tools, add since/method/status/limit params to
  browser_network, remove Extension dependency hints
- Shared: export additional types for daemon consumption

Bug fixes from harness testing:
- Invalid tab ID now errors instead of silent fallback
- tab_new works with zero existing tabs
- console.warn() correctly captured as type "warn"
- --tab flag works with tab close command

Closes #131

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 11:02:48 +08:00
Yanwu 1fe733b416 feat: auto-launch Chrome in bb-browserd + clip.json (#123)
* fix: auto-reconnect after Hub restart

Two bugs prevented reconnection when pinixd restarts:

1. reconnectTimer was unref'd via maybeUnref(), so it didn't keep the
   event loop alive — the setTimeout callback never fired
2. gRPC transport was reused across reconnects, causing "protocol error:
   missing status" loops from stale HTTP/2 connection state

Fix: remove maybeUnref on reconnect timer, create fresh transport on
each reconnect attempt, remove unused runPromise guard.

Closes #103

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: auto-launch Chrome when CDP not available in bb-browserd

bb-browserd now automatically starts a managed Chrome instance if no
CDP connection is found, instead of failing with "Chrome not reachable".

Also adds clip.json for Pinix Registry publishing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 17:42:51 +08:00
Yanwu ef4f6849e4 fix: auto-reconnect after Hub restart (#111)
Two bugs prevented reconnection when pinixd restarts:

1. reconnectTimer was unref'd via maybeUnref(), so it didn't keep the
   event loop alive — the setTimeout callback never fired
2. gRPC transport was reused across reconnects, causing "protocol error:
   missing status" loops from stale HTTP/2 connection state

Fix: remove maybeUnref on reconnect timer, create fresh transport on
each reconnect attempt, remove unused runPromise guard.

Closes #103

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 15:34:56 +08:00
yan5xu 7ea9481a0d chore: remove pinix.json — manifest is now runtime-only
Part of manifest file removal across Pinix ecosystem (epiral/pinix#47).
Clip identity comes from package.json; commands/domain/etc from SDK code at runtime.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 15:50:38 +08:00
yan5xu 4ad258994b release: v0.10.1
Fixes:
- fix: remove replMode from CDP evaluate to fix async/Promise results
- fix: open new tabs in background (background: true)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 19:49:09 +08:00
yan5xu 54e02b0265 feat: add pinix.json (Edge Clip manifest) 2026-03-22 18:14:17 +08:00
yan5xu ad3898347a docs: add resilient adapter patterns (structural DOM, webpack discovery)
- Pattern 1: Structural DOM extraction using semantic HTML elements
  instead of CSS classes (Google search example)
- Pattern 2: Dynamic webpack module discovery by source code signatures
  instead of hardcoded module IDs (Twitter/X example)
- Pattern 3: Vue/React internal state access

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 15:31:02 +08:00
yan5xu ea6f08c007 fix: remove replMode from CDP evaluate to fix async/Promise results
replMode: true caused Chrome to treat Promise values as plain objects,
bypassing awaitPromise: true. This made all async site adapters
(twitter/reply, twitter/search, etc.) return empty {} instead of
actual results.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 15:21:57 +08:00
yan5xu b9ee3aaca2 fix: add Chrome Dev/Beta/Canary and Brave to Windows browser candidates
Chrome Dev installs to %LOCALAPPDATA% on Windows, not Program Files.
Without these paths bb-browser falls through to Edge even when Chrome
Dev is installed.

Fixes feedback from @NormanMises_

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 15:05:16 +08:00
yan5xu ee2c404245 fix: follow-up fixes for merged PRs #82, #91, #25
- #82: extract EXEC_TIMEOUT_BUFFER_MS constant for magic number 5000
- #91: remove failed tabs from sessionOpenedTabs to prevent stale entries
- #25: update platform/command counts from 35/97 to 36/103

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 14:40:45 +08:00
aichunyu d65f3c3ca1 docs(skill): 补全 bb-browser skill 文档,新增 site/fetch/network/adapter 参考文档 (#25)
- 更新 SKILL.md:新增 site 系统、fetch 命令、snapshot 高级选项、全局 --tab、MCP 集成、network 高级功能
- 新增 references/site-system.md:35 平台完整列表、自动 tab 管理、参数传递、错误处理
- 新增 references/fetch-and-network.md:带登录态 fetch、域名路由、请求拦截与 mock、API 逆向工程工作流
- 新增 references/adapter-development.md:三层复杂度指南、元数据格式、测试与贡献流程

Co-authored-by: 艾纯禹 <aquaqu@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-22 14:38:10 +08:00
Ted Li cfa1b0fd8b feat(mcp): add session tab cleanup tool (#91) 2026-03-22 14:37:59 +08:00
Waffle 7c2ee5e14e fix(cli): pass timeout through to OpenClaw (#82)
* fix(cli): pass timeout through to OpenClaw

* fix(cli): scope openclaw timeout to subcommands
2026-03-22 14:37:55 +08:00
Ted Li 45c1fbb385 fix(shared): avoid global crypto for request ids (#89) 2026-03-22 14:36:05 +08:00
Waffle 1316679fd9 chore(github): add issue templates (#83)
* chore(github): add issue templates

* chore(github): add issue template labels and checkboxes
2026-03-22 14:36:02 +08:00
yan5xu 57da2779d3 ci: fix publish — use workflow_call instead of release event
GITHUB_TOKEN-created releases don't trigger other workflows (GitHub
Actions limitation to prevent loops). Changed publish.yml to use
workflow_call (invoked by release-please) + workflow_dispatch (manual
retry from Actions tab).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 14:22:00 +08:00
github-actions[bot] 2a41d67a27 chore(main): release bb-browser 0.10.0 (#93)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
bb-browser-v0.10.0
2026-03-22 14:20:37 +08:00
yan5xu e50dae2278 ci: split publish into separate workflow triggered by release event
Previously all publish steps lived in release-please.yml gated on
release_created. If the release-please run failed (e.g. permissions)
but the release was created manually, npm publish could never be
retried — subsequent runs saw the release already existed and skipped.

Now release-please.yml only manages PRs/releases, and a new
publish.yml triggers on release:published to handle build, extension
upload, and npm publish independently. Publish failures can be re-run
without needing release-please to fire again.

Closes #94

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 14:19:20 +08:00
yan5xu 6d8f18b393 fix: open new tabs in background to avoid bringing Chrome to foreground
Add `background: true` to both `Target.createTarget` CDP calls so that
`bb-browser open --tab` and `bb-browser tab new` no longer activate the
Chrome window. This prevents disrupting the user's workflow when agents
run browser automation in the background.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 12:33:24 +08:00
yan5xu e730b0ef55 feat: bb-browserd migrate from WebSocket to Connect-RPC ProviderStream
Replace WebSocket /ws/provider with Connect-RPC ProviderStream for
communicating with pinixd Hub. Same functionality, unified protocol.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 00:02:28 +08:00
yan5xu 2ce47c55ce feat: bb-browserd CDP direct connection (replaces daemon HTTP)
- Connect directly to Chrome CDP WebSocket instead of daemon HTTP
- No Chrome Extension needed, same as CLI's cdp-client approach
- Lazy CDP initialization on first command
- Commands: navigate, click, type, evaluate, screenshot, getCookies, waitForSelector
- Verified: navigate returns {url, title}, evaluate returns {result}

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 22:34:24 +08:00
yan5xu 3af2b4c856 feat: bb-browserd — Pinix capability adapter
Single-file bridge: WebSocket to pinixd + HTTP to bb-browser daemon.
Registers browser capability with 7 commands: navigate, click, type,
evaluate, screenshot, getCookies, waitForSelector.
Auto-reconnect on disconnect.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 17:03:13 +08:00
Yanwu 0ae6dc6970 Merge pull request #88 from epiral/release-please--branches--main--components--bb-browser
chore(main): release bb-browser 0.9.0
bb-browser-v0.9.0
2026-03-20 00:14:07 +08:00
github-actions[bot] 2f2e153ef1 chore(main): release bb-browser 0.9.0 2026-03-19 16:08:24 +00:00
Yanwu aa3010f015 Merge pull request #87 from epiral/feat/cdp-monitor
feat(cli): add CDP monitor for persistent monitoring
2026-03-19 23:51:23 +08:00
yan5xu 94c94b7c4e feat(cli): add CDP monitor background process for persistent monitoring (Phase 1, #77)
Monitoring commands (network, console, errors, trace) are broken in
direct CDP mode because each CLI invocation is a new short-lived
process that cannot accumulate events over time.

This introduces a long-running background monitor process that
maintains a persistent CDP connection and collects events:

- cdp-monitor-state.ts: MonitorState class extracted from cdp-client.ts
  event handling logic (Network.*, Runtime.*, trace)
- cdp-monitor.ts: standalone Node.js process that connects to Chrome
  via CDP, attaches to all page targets, and serves an HTTP API on
  127.0.0.1 with bearer-token auth
- monitor-manager.ts: CLI-side lifecycle management (spawn, health
  check, shutdown, command forwarding)
- client.ts: routes monitor actions (network/console/errors/trace)
  through the monitor with graceful fallback to direct CDP
- tsup.config.ts: adds cdp-monitor as a build entry point

The monitor auto-discovers new tabs, writes PID/port/token files to
~/.bb-browser/, and auto-exits after 30 minutes of inactivity.
cdp-client.ts is intentionally left untouched to avoid regressions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 23:47:12 +08:00
Yanwu 1215b01604 Merge pull request #86 from ox01024/chore/release-please
chore(release): automate versioning and publishing
2026-03-19 20:17:28 +08:00
Yanwu 22d38c1368 Merge pull request #67 from MonkeyLeeT/codex/mcp-site-tools
feat(mcp): add site adapter tools
2026-03-19 20:15:59 +08:00
Yanwu 3a1541114f Merge pull request #69 from ox01024/fix/status-command-help
fix(cli): wire top-level status command
2026-03-19 20:15:22 +08:00
Yanwu a391b8241a Merge pull request #63 from MonkeyLeeT/codex/fix-eval-top-level-await
Clean fix using replMode: true — same approach as Chrome DevTools Console. No side effects on existing expressions. LGTM.
2026-03-19 20:14:39 +08:00
Yanwu 3659fb869a Merge pull request #74 from ox01024/fix/click-navigation
Fixes real click-offset bug on scrolled pages. Viewport coordinate transformation is correct. LGTM.
2026-03-19 20:14:29 +08:00