Skip to content

Commit 9cdc127

Browse files
authored
feat: add doubao browser adapter (#277)
1 parent a6d993f commit 9cdc127

10 files changed

Lines changed: 791 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ Run `opencli list` for the live registry.
105105
| **bilibili** | `hot` `search` `me` `favorite` `history` `feed` `subtitle` `dynamic` `ranking` `following` `user-videos` `download` | Browser |
106106
| **codex** | `status` `send` `read` `new` `dump` `extract-diff` `model` `ask` `screenshot` `history` `export` | Desktop |
107107
| **chatwise** | `status` `new` `send` `read` `ask` `model` `history` `export` `screenshot` | Desktop |
108+
| **doubao** | `status` `new` `send` `read` `ask` | Browser |
108109
| **notion** | `status` `search` `read` `new` `write` `sidebar` `favorites` `export` | Desktop |
109110
| **discord-app** | `status` `send` `read` `channels` `servers` `search` `members` | Desktop |
110111
| **v2ex** | `hot` `latest` `topic` `daily` `me` `notifications` | Public / Browser |

README.zh-CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ npm install -g @jackwener/opencli@latest
107107
| **bilibili** | `hot` `search` `me` `favorite` `history` `feed` `subtitle` `dynamic` `ranking` `following` `user-videos` `download` | 浏览器 |
108108
| **codex** | `status` `send` `read` `new` `dump` `extract-diff` `model` `ask` `screenshot` `history` `export` | 桌面端 |
109109
| **chatwise** | `status` `new` `send` `read` `ask` `model` `history` `export` `screenshot` | 桌面端 |
110+
| **doubao** | `status` `new` `send` `read` `ask` | 浏览器 |
110111
| **notion** | `status` `search` `read` `new` `write` `sidebar` `favorites` `export` | 桌面端 |
111112
| **discord-app** | `status` `send` `read` `channels` `servers` `search` `members` | 桌面端 |
112113
| **v2ex** | `hot` `latest` `topic` `daily` `me` `notifications` | 公开 / 浏览器 |

docs/adapters/browser/doubao.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# doubao
2+
3+
Browser adapter for [Doubao Chat](https://www.doubao.com/chat).
4+
5+
## Commands
6+
7+
| Command | Description |
8+
|---------|-------------|
9+
| `opencli doubao status` | Check whether the page is reachable and whether Doubao appears logged in |
10+
| `opencli doubao new` | Start a new Doubao conversation |
11+
| `opencli doubao send "..."` | Send a message to the current Doubao chat |
12+
| `opencli doubao read` | Read the visible Doubao conversation |
13+
| `opencli doubao ask "..."` | Send a prompt and wait for a reply |
14+
15+
## Prerequisites
16+
17+
- Chrome is running
18+
- You are already logged into [doubao.com](https://www.doubao.com/)
19+
- Playwright MCP Bridge / browser bridge is configured for OpenCLI
20+
21+
## Examples
22+
23+
```bash
24+
opencli doubao status
25+
opencli doubao new
26+
opencli doubao send "帮我总结这段文档"
27+
opencli doubao read
28+
opencli doubao ask "请写一个 Python 快速排序示例" --timeout 90
29+
```
30+
31+
## Notes
32+
33+
- The adapter targets the web chat page at `https://www.doubao.com/chat`
34+
- `new` first tries the visible "New Chat / 新对话" button, then falls back to the new-thread route
35+
- `ask` uses DOM polling, so very long generations may need a larger `--timeout`

docs/adapters/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Run `opencli list` for the live registry.
2727
| **[linux-do](/adapters/browser/linux-do)** | `hot` `latest` `categories` `category` `search` `topic` | 🔐 Browser |
2828
| **[chaoxing](/adapters/browser/chaoxing)** | `assignments` `exams` | 🔐 Browser |
2929
| **[grok](/adapters/browser/grok)** | `ask` | 🔐 Browser |
30+
| **[doubao](/adapters/browser/doubao)** | `status` `new` `send` `read` `ask` | 🔐 Browser |
3031
| **[weread](/adapters/browser/weread)** | `shelf` `search` `book` `ranking` `notebooks` `highlights` `notes` | 🔐 Browser |
3132

3233
## Public API Adapters

src/clis/doubao/ask.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { cli, Strategy } from '../../registry.js';
2+
import type { IPage } from '../../types.js';
3+
import { DOUBAO_DOMAIN, getDoubaoTranscriptLines, getDoubaoVisibleTurns, sendDoubaoMessage, waitForDoubaoResponse } from './common.js';
4+
5+
export const askCommand = cli({
6+
site: 'doubao',
7+
name: 'ask',
8+
description: 'Send a prompt and wait for the Doubao response',
9+
domain: DOUBAO_DOMAIN,
10+
strategy: Strategy.COOKIE,
11+
browser: true,
12+
navigateBefore: false,
13+
timeoutSeconds: 180,
14+
args: [
15+
{ name: 'text', required: true, positional: true, help: 'Prompt to send' },
16+
{ name: 'timeout', required: false, help: 'Max seconds to wait (default: 60)', default: '60' },
17+
],
18+
columns: ['Role', 'Text'],
19+
func: async (page: IPage, kwargs: any) => {
20+
const text = kwargs.text as string;
21+
const timeout = parseInt(kwargs.timeout as string, 10) || 60;
22+
const beforeTurns = await getDoubaoVisibleTurns(page);
23+
const beforeLines = await getDoubaoTranscriptLines(page);
24+
25+
await sendDoubaoMessage(page, text);
26+
const response = await waitForDoubaoResponse(page, beforeLines, beforeTurns, text, timeout);
27+
28+
if (!response) {
29+
return [
30+
{ Role: 'User', Text: text },
31+
{ Role: 'System', Text: `No response within ${timeout}s. Doubao may still be generating.` },
32+
];
33+
}
34+
35+
return [
36+
{ Role: 'User', Text: text },
37+
{ Role: 'Assistant', Text: response },
38+
];
39+
},
40+
});

0 commit comments

Comments
 (0)