Skip to content

feat: add --gstack mode for GStack Desktop integration#120

Open
lancepan123 wants to merge 1 commit intoepiral:mainfrom
lancepan123:feat/gstack-mode
Open

feat: add --gstack mode for GStack Desktop integration#120
lancepan123 wants to merge 1 commit intoepiral:mainfrom
lancepan123:feat/gstack-mode

Conversation

@lancepan123
Copy link
Copy Markdown

Summary

Add a new --gstack flag that routes browser commands through GStack Desktop's Unix domain socket IPC instead of discovering a CDP endpoint automatically.

This enables bb-browser CLI to drive an Electron-based desktop app (GStack Desktop) via its IPC interface, while preserving full CDP fallback for unsupported operations.

Changes

File Description
packages/cli/src/gstack-bridge.ts New — Bridge module (execFileSync → gstack CLI → IPC socket). Exports: gstackGetTabs, gstackFindTabByDomain, gstackOpenTab, gstackEvaluate, gstackScreenshot, gstackNavigate
packages/cli/src/index.ts --gstack flag parsing, handleGstackCommand() intercept layer in main() — supported commands: open, screenshot, tab, eval, back/forward/refresh; unsupported commands fall through to CDP
packages/cli/src/commands/site.ts GStack execution path in siteRun() — tab discovery by domain → open if needed → evaluate adapter script → auth error detection
packages/cli/src/cdp-client.ts createTargetWithFallback() — gracefully handles runtimes where Target.createTarget is not supported (e.g. some Electron builds)
packages/cli/src/commands/open.ts Relax tabId parsing to accept both numeric index and string/UUID IDs

How it works

bb open https://example.com --gstack
#  → gstack CLI → Unix socket (~/.gstack/ipc.sock) → Electron IPC → BrowserWindow

When --gstack is set:

  1. handleGstackCommand() intercepts known commands and routes them via gstack-bridge.ts
  2. Unknown commands fall through to the normal CDP dispatch path
  3. site command uses gstack tab discovery + evaluate instead of CDP Runtime.evaluate

Testing

  • Build: pnpm build passes with zero TS errors
  • Runtime verified: IPC ping, snapshot, click, fill, evaluate all working
  • CDP fallback verified: snapshot, click, fill work normally when --gstack is not set

Add a new --gstack flag that routes browser commands through GStack Desktop's
Unix domain socket IPC instead of discovering a CDP endpoint automatically.

Changes:
- gstack-bridge.ts: new bridge module (execFileSync → gstack CLI → IPC socket)
- index.ts: --gstack flag parsing, handleGstackCommand() intercept layer
- site.ts: gstack execution path with tab discovery + evaluate + auth detection
- cdp-client.ts: createTargetWithFallback() for runtimes without Target.createTarget
- open.ts: relax tabId parsing to accept both numeric and string/UUID IDs
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.

1 participant