Doubao Work runs its agent loop in ByteDance's cloud and has no API. This
plugin uses the desktop app the way a person does and gives the reply back
as an OpenAI chat completion:
- cdp.mjs (knows nothing about Doubao): starts a Chromium-based app from a
profile of its own with DevTools on a port it picked and saved, reuses it
while it runs, never kills anything; Page evaluates and presses keys.
- doubao.mjs: per request a new 工作任务, switched to 云电脑 (Doubao's agent
never touches this computer), the model picked (Pro needs a paid plan:
403), the whole request written into tiptap one paragraph a line, Enter,
and the reply read from the message's content_blocks_v2 (markdown, and
thinking as reasoning_content) until is_finish. One request at a time.
- prompt.mjs / openai.mjs: system prompt, tools and turns flattened into one
message; tools asked for as <tool_call>{json}</tool_call> and given back
as tool_calls; SSE that holds text from the first call (or a tail that
may start one), and that throws a failure before the reply begins so it
goes back as an HTTP error.
- Sign-in waits for the account in the separate Doubao window.
Run:
- bun test packages/doubao-work on mote: 24 pass.
- Full suite on mote the way CI runs it (HOME=$(mktemp -d) bun test):
6936 pass, 20 skip, 0 fail. bun scripts/check.mjs: doubao-work ok.
- Broken by hand: sleep without its aborted check; "an abort between two
polls stops the ask too" goes red (runs to the 180s idle timeout), green
with it. Found by the first run: an abort landing between polls was lost.
- Live, the loader against a signed-in Doubao 147 on macOS: auto plain
answer 200 in 3.9s; doubao-2.1-lite streamed Bash tool call (first byte
3.6s, total 4.8s); tool result follow-up answered "412 lines"; Pro gave
403 doubao_upgrade; a 300-word story streamed as 20 content deltas with
its ```python fence kept; a client abort ended the stream and the next
request answered 200.
Not tried: through magpie's plugin host and a real agent (Claude Code
sized requests); Windows and Linux (unsupported, sign-in says so). A
stopped request stops being read but Doubao finishes its task (README).