Signing in with "Read Tabbit Browser sign-in" failed at once, with no
Keychain prompt, as "Command failed: security find-generic-password -s
Tabbit Browser Safe Storage -w" (shiqi_40904, Discord, macOS 27.2).
Cause: Tabbit ships two macOS builds, and the plugin knew only one
Keychain name. Read out of both 1.16.27 installers (Info.plist, and the
framework code that picks the name from a flag set at start-up):
- Tabbit.app (com.tabbit-ai.Tabbit, international): data folder
~/Library/Application Support/Tabbit, service "Tabbit Safe Storage",
account "Tabbit".
- Tabbit Browser.app (com.tab-browser.Tabbit, China): data folder
"Tabbit Browser", service "Tabbit Browser Safe Storage", account
"Tabbit Browser".
The plugin found the international store and asked for the China name;
security answered "item not found" (exit 44) with no prompt. The spaces
were never the problem: the name was already one argv entry, and the
message is only Node's way of printing the command.
Now:
- Each store asks its own build's item first, then the other's.
Not found moves on at once; security only prompts for an item that
exists, so a not-found never waits for a prompt.
- With both builds installed, the store that is signed in is read.
- The Keychain call is async with a 2-minute timeout (it was a 15 s
execFileSync that dropped stderr), so the user has time to answer.
- Errors say what to do: not installed or not signed in -> open Tabbit
and sign in; not in the Keychain under either name (both named);
prompt denied (128/51) -> click Allow; no answer in time; keychain
locked (36); anything else carries security's own stderr. Each
points at "Paste Tabbit token".
- The method is now "Read the Tabbit app's sign-in (macOS)"; README
lists both builds.
Run on mote (macOS, Node 22.22.0, Bun):
- node --test tests/*.test.mjs: 83 pass, 0 fail. bun test (temp HOME):
83 pass. bun scripts/check.mjs: exit 0.
- Broken by hand: safeStorageNames returning only the China name (the
old behaviour) turned 3 tests red, among them "the international
build signs in with its Tabbit Safe Storage item (the report)".
- Again after rebasing onto ff9d3a64 (the pushed parent; it changed only
system-prompt and trae): tabbit node --test 83 pass, whole-repo
bun test (temp HOME) 7588 pass 0 fail, check exit 0.
- Tests use a fake security and fixture cookie stores; nothing reads
this machine's Keychain or browser profiles.
Not tried: a real Tabbit account or a real Keychain prompt (none here),
so the prompt's exit codes come from Security.framework's OSStatus
values, not a recorded run. Dev builds' "TabbitDev ..." names are not
tried. magpie pins no min for tabbit (git grep finds none).
Reported-by: shiqi_40904 (Discord)
214 lines
10 KiB
Markdown
214 lines
10 KiB
Markdown
# Tabbit for magpie
|
||
|
||
[Tabbit](https://web.tabbit.com) as a provider in [magpie](https://usemagpie.ai)
|
||
(and OpenCode). It signs in with the Tabbit account already on this
|
||
computer, lists the account's real model catalog, and answers turns through
|
||
Tabbit's own chat API — so an agent behind magpie can pick `tabbit/Default`,
|
||
`tabbit/DeepSeek-V4.1-Flash`, `tabbit/GLM-5.3-Flash` and the rest like any
|
||
other provider, with the account's allowance, fallbacks and usage card.
|
||
|
||
## Install
|
||
|
||
```sh
|
||
magpie plugin add @magpie-community/opencode-tabbit-auth # from the community list
|
||
# from this source tree instead: magpie plugin add .
|
||
magpie plugin login tabbit # pick “Read the Tabbit app's sign-in (macOS)”
|
||
magpie provider test tabbit # ✓ chat · Default
|
||
```
|
||
|
||
Then pick `tabbit/<model>` in any agent's model row on magpie's Agents page —
|
||
or route to it from a group:
|
||
|
||
```sh
|
||
magpie group add tabbit-pool models=tabbit/Default,tabbit/DeepSeek-V4.1-Flash routing=cheap
|
||
```
|
||
|
||
**每日自动签到**:装好并登录后,magpie → 设置 →「窗口重置时预热 / 每日自动签到」→
|
||
标签条最右的 **插件** → 「Tabbit · 每日自动签到」打开开关(还有「立即签到」按钮)。
|
||
Tabbit 的签到就是桌面宠物那个活动,结果会画在用量卡片上。
|
||
|
||
**OpenCode**:`opencode.json` 里加 `{ "plugin": ["@magpie-community/opencode-tabbit-auth"] }`,
|
||
再 `opencode auth login`。
|
||
|
||
**Provider id:** `tabbit`
|
||
|
||
This is not Tabbit's official API. It uses the endpoints Tabbit's own web app
|
||
calls, with the sign-in that app keeps, for one person on their own machine.
|
||
|
||
## Sign-in
|
||
|
||
Tabbit's sign-in is a `token` cookie: an RS256 JWT issued by
|
||
`web.tab-browser.com` with a **7-day** life. Two ways in:
|
||
|
||
| Method | What it does |
|
||
|---|---|
|
||
| **Read the Tabbit app's sign-in** (macOS) | Finds the cookie store Tabbit keeps, reads the `token` cookie, and decrypts it with the password in the login keychain. The international build (Tabbit.app) keeps its store in `~/Library/Application Support/Tabbit` and the password under `Tabbit Safe Storage`; the China build (Tabbit Browser.app) in `~/Library/Application Support/Tabbit Browser`, under `Tabbit Browser Safe Storage`. Each store is read with its own build's item first, then the other's. macOS asks once for Keychain access: click Allow (or Always Allow). Nothing is copied by hand; the browser does not have to be closed — the database is copied before it is read. |
|
||
| **Paste Tabbit token** | For anything the first method can't reach (Windows or Linux, a browser profile kept somewhere else). In Tabbit Browser, open `web.tabbit.com` (or `web.tabbit.ai` for an international account) and read the `token` cookie from the developer tools; paste it whole. |
|
||
|
||
A pasted value may be the bare JWT or a whole `name=value; name=value` cookie
|
||
string. The account id is read out of the token itself, so nothing else has to
|
||
be pasted.
|
||
|
||
**Two sites.** Tabbit runs `web.tabbit.com` and, for international accounts,
|
||
`web.tabbit.ai`: the same API, but a token from one is refused on the other
|
||
(#833). Nothing is set by hand. The desktop method records the site whose
|
||
cookie it found. A pasted token goes to `web.tabbit.com` first; when that
|
||
refuses it, `web.tabbit.ai` is asked once, and the site that accepts it serves
|
||
that token from then on (a token both refuse is an expired sign-in, as
|
||
before). A `web.tabbit.com` token never asks `web.tabbit.ai` anything.
|
||
|
||
> **International site, chat turns:** `web.tabbit.ai` answers a turn's
|
||
> `runs` call with `429`, code `492` ("Welcome to Tabbit Browser...") unless
|
||
> the request carries a `unique-uuid` header — the browser sends a fresh
|
||
> uuid on every API call, and the gate accepts any well-formed one (a
|
||
> net-export capture of Tabbit Browser's own traffic showed the header on
|
||
> `runs`, `join` and `usage`). The plugin sends one per call (#834).
|
||
|
||
There is no refresh endpoint. When the token runs out (7 days), magpie shows
|
||
the account as needing a sign-in again and the first method takes one more
|
||
click.
|
||
|
||
> **macOS only.** Reading the desktop's cookie is implemented for macOS. On
|
||
> Windows the store is DPAPI-encrypted and on Linux it uses a different store
|
||
> key; neither is done here. On those platforms the method refuses and names
|
||
> the platform, and the paste method is the one to use.
|
||
|
||
## Models
|
||
|
||
The catalog comes from the account:
|
||
`GET /proxy/v1/model_config/models?a=0&scene=chat` — the same call the Tabbit
|
||
app makes. A model's **id is the catalog's `display_name`, verbatim**
|
||
(`DeepSeek-V4.1-Flash`, `GLM-5.3-Flash`…), because that is the name a turn has
|
||
to be asked with.
|
||
|
||
| Catalog field | Becomes |
|
||
|---|---|
|
||
| `display_name` | the model id and name |
|
||
| `supports_images` | image input on the row |
|
||
| `support_thinking` | the reasoning flag (thinking arrives as `reasoning_content`) |
|
||
| `model_access_type` | `free_unlimited` / `free_metered` / `premium_only` |
|
||
| `hidden` | left out, as the app leaves it out |
|
||
|
||
**Client tools are off** (`toolcall: false`). The catalog's `supports_tools`
|
||
means Tabbit's *own* server-side tools — browser and search — not tools an
|
||
agent declares: a turn asked to call a client-declared tool answers that it has
|
||
no such tool. A tool-using agent should go through magpie's gateway tools
|
||
instead.
|
||
|
||
**Limits are not published** by Tabbit. Known ones are hard-coded
|
||
(`DeepSeek-V4.1-Flash` and `DeepSeek-V4-Pro`: 1M context); everything else
|
||
takes a default (`TABBIT_CONTEXT`, `TABBIT_OUTPUT`, 128k / 32k). A prompt past
|
||
a real limit comes back as Tabbit's own error.
|
||
|
||
**Premium models** answer `403` with code `492` on a free account. The
|
||
**Free models only** switch in the provider's options leaves them out of the
|
||
list instead of letting them fail at the turn.
|
||
|
||
## Daily check-in (签到)
|
||
|
||
Tabbit's check-in is the desktop pet's activity, and it runs on
|
||
`/api/commerce/activity/v1/sign-in` — the same two calls the browser makes:
|
||
|
||
```
|
||
GET /api/commerce/activity/v1/sign-in/status?scene_codes=desktop_pet
|
||
POST /api/commerce/activity/v1/sign-in {request_no, scene_codes:["desktop_pet"]}
|
||
```
|
||
|
||
The plugin implements magpie's `auth.checkin` hook, so it appears where
|
||
WorkBuddy's does: **Settings → Usage → Plugins → Tabbit**, on by default after
|
||
you flip it, and magpie then runs it once a day per account and draws the
|
||
outcome on the account's card.
|
||
|
||
It reads the status first — free, and it says whether the activity is open —
|
||
and only claims when the day is actually unsigned. What Tabbit's answers
|
||
become:
|
||
|
||
| Tabbit says | The card shows |
|
||
|---|---|
|
||
| `signed_today: true` | **done** (no claim is sent at all) |
|
||
| `sign_in_result: "signed"` | **claimed**, with the usage it granted and the day count |
|
||
| `sign_in_result: "already_signed"` | **done** (a race, not a failure) |
|
||
| `activity_open: false` | **inactive** |
|
||
| no result for the scene | **ineligible** |
|
||
| any other word | **failed**, carrying Tabbit's own word for it |
|
||
|
||
`desktop_pet` is the only scene the service accepts — every other name comes
|
||
back `SIGN_IN_SCENE_UNSUPPORTED`. The pet itself needs `required_days` (3)
|
||
before it can be adopted, so a signed day also reports the streak
|
||
(`1/3 days`).
|
||
|
||
A `sign_in_result` this plugin hasn't seen is reported as a failure rather
|
||
than guessed as a claim: a wrong "claimed" is worse than a failure you can
|
||
read.
|
||
|
||
## Usage
|
||
|
||
`GET /api/commerce/quota/v1/usage` gives the cycle's allowance, which the
|
||
Usage card shows as **Cycle usage** — a percentage, with when the cycle resets
|
||
(Tabbit's cycles are weekly, named in Beijing time).
|
||
|
||
## How a turn is sent
|
||
|
||
`loader()` hands magpie a `fetch` that rewrites `chat/completions` into the
|
||
three calls Tabbit's app makes:
|
||
|
||
```
|
||
POST /api/v3/chat/rooms → a room (the conversation)
|
||
POST /api/v3/chat/rooms/<room>/runs → the turn: { content, selected_model }
|
||
POST /api/v3/chat/rooms/<room>/join → text/event-stream
|
||
```
|
||
|
||
The stream is written back as OpenAI chunks: `assistant_message_delta` →
|
||
`choices[].delta.content`, `event_message_chunk(thinking)` →
|
||
`reasoning_content`, `run_completed` → `finish_reason: "stop"`. A turn that
|
||
ends without `run_completed` or `run_failed` — the stream cut, the turn timing
|
||
out — comes back as an error event, not as a short answer: an agent would
|
||
otherwise take a half or empty reply as the answer. A turn that times out also
|
||
sends `chat/stop`, so it stops spending the account's allowance.
|
||
|
||
**Conversation history** lives in the room. Each magpie session is given one
|
||
room (`chat.headers` carries the session id), so a follow-up inside a session
|
||
sends only the new message and hangs it off the previous answer's id — the room
|
||
is not replayed into the prompt. A request whose transcript doesn't continue
|
||
the room (a new session, an edited history, a room Tabbit reset) gets a fresh
|
||
room with the whole transcript flattened into one prompt; measured, the model
|
||
answers the last question with the earlier turns as context.
|
||
|
||
`maxConcurrency` is **1**: Tabbit answers one turn at a time.
|
||
|
||
## Working on this package
|
||
|
||
From a checkout of this source tree, or from the published package:
|
||
|
||
```sh
|
||
magpie plugin add . # this checkout; the community list has the package
|
||
magpie plugin login tabbit # or: pick the provider in the app
|
||
magpie provider test tabbit
|
||
magpie models tabbit
|
||
```
|
||
|
||
In OpenCode, add `@magpie-community/opencode-tabbit-auth` under `plugin` and
|
||
sign in with `opencode auth login`.
|
||
|
||
## Development
|
||
|
||
```sh
|
||
node --test tests/*.test.mjs # Bun: `bun test`. Every hook, a synthetic
|
||
# cookie store, a replayed SSE turn
|
||
node scripts/check.mjs # loads the hooks the way magpie and OpenCode do
|
||
```
|
||
|
||
The tests never touch the network. `tests/plugin.test.mjs` stubs Tabbit's four
|
||
endpoints; `tests/sse.test.mjs` replays a recorded turn, including a rejoin's
|
||
snapshot and a turn cut short; `tests/cookie.test.mjs` seals and unseals a
|
||
synthetic Chromium `v10` blob.
|
||
|
||
## Limits worth knowing
|
||
|
||
- A turn is a web-app turn: first text takes seconds, and one turn runs at a
|
||
time.
|
||
- Tabbit keeps the room's own history, so a flattened prompt is the fallback
|
||
path, not the normal one. Very long transcripts past the model's limit are
|
||
Tabbit's call, and it answers with its own error.
|
||
- The catalog call answers without a valid token; a token that has really
|
||
expired shows up at the first turn (`401 请先登录`), which marks the account. |