Files
epiral__bb-browser/packages/shared/package.json
Yanwu fd0d7956e2 feat: unified command registry for CLI/MCP/Edge Clip (#171)
* feat: add unified command registry (shared/commands.ts)

Single source of truth for all 30+ commands. CLI/MCP/Edge Clip
will auto-generate interfaces from this registry.

Part of #170

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

* fix: complete command registry (history args, fetch, site commands)

- Add missing `query` and `days` args to `history` command
- Add 6 site commands: site_list, site_search, site_info, site_recommend,
  site_run, site_update (category: "site")
- Verified `tab_new` is a real dispatch case (handled before ensurePageTarget)
- Verified `get` attribute enum is complete (text, url, title, value, html)
- Confirmed `fetch` is CLI-only (composes eval), not a daemon action — skip

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

* refactor: use Zod schemas in command registry

Replace custom CommandArg interface with Zod schemas for runtime
validation, JSON Schema generation, and zero-conversion MCP integration.

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

* refactor: MCP + Edge Clip auto-generate from command registry

MCP: 25 → 37 tools, auto-generated from COMMANDS registry.
13 new tools: back, forward, refresh, check, uncheck, select,
dialog, frame, frame_main, tab_select, tab_close, trace, history.
Special handlers preserved for snapshot/screenshot/eval/network etc.

Edge Clip: 7 → 37 commands. Removed all direct CDP code (~400 lines).
Now routes through daemon HTTP API like CLI and MCP.
Uses inline zod-to-json-schema converter for Hub registration.

Adding a new command = 1 registry entry + 1 dispatch case.
All three interfaces (CLI/MCP/Edge Clip) get it automatically.

Part of #170

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

* fix: address review issues (since type, MCP compat, description loss, scroll default)

- Fix since field type: use z.union([z.literal("last_action"), z.number()])
  instead of z.string() for network/console/errors commands
- Add MCP backward compat: accept old arg names (time, command) alongside
  new ones (ms, networkCommand, consoleCommand, errorsCommand)
- Fix bb-browserd ZodOptional/ZodDefault unwrap losing outer description
- Fix typo: executeViaDeamon → executeViaDaemon
- Remove unnecessary tab arg from history command (daemon mode unsupported)

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

* fix: prefix unused cmd params with underscore for lint

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

* fix: route Edge Clip site commands through CLI instead of daemon

Site commands (site_list, site_run, etc.) are handled by CLI, not
daemon. Edge Clip now routes them via CLI execFile, matching MCP's
approach. Other commands still go through daemon HTTP API.

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

* fix: Edge Clip site commands use installed bb-browser CLI, not source

bun running CLI source fails because __BB_BROWSER_VERSION__ is a tsup
define not available at runtime. Use installed bb-browser binary with
fallback to dist/cli.js.

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-05 22:16:28 +08:00

31 lines
563 B
JSON

{
"name": "@bb-browser/shared",
"version": "0.0.1",
"type": "module",
"exports": {
".": {
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
}
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "tsup",
"dev": "tsup --watch",
"clean": "rm -rf dist",
"lint": "eslint src tsup.config.ts"
},
"devDependencies": {
"@types/node": "^22.0.0",
"tsup": "^8.3.0",
"typescript": "^5.7.0"
},
"dependencies": {
"zod": "^3.24.1"
}
}