tabbit 0.1.1: international accounts are served by web.tabbit.ai (#833)

Tabbit runs two sites with one API: web.tabbit.com (China) and
web.tabbit.ai (international). Each site refuses the other's tokens.
The plugin only knew .com, so every international account was refused
with 401 "invalid bearer". The reporter saw this as a lost sign-in.

The site is now picked by the account, with nothing to set:
- A desktop sign-in reads the token from whichever host's cookie has
  it, web.tabbit.com or web.tabbit.ai. The host's own hash prefix
  unseals it, and the site is recorded in the account's metadata.site.
- A pasted token, or an account from before this change, starts on
  .com. If .com refuses it, the same request is sent once to .ai.
  - If .ai accepts it, the token is remembered as .ai's for the process.
  - If both sites refuse it, it stays on .com and is reported as an
    expired sign-in, as before.
  - If .ai can't be reached, nothing is settled.
  - A 429 or 5xx settles nothing either.
- The catalog answers any token, so it settles nothing. The model list
  asks usage first to learn the site, so an international account gets
  .ai's catalog.
- Origin and Referer follow the site.

Not fixed here: .ai answers a chat run with 429 code 492 ("Welcome to
Tabbit Browser"), its browser sign-in gate. Sign-in, the model list,
usage and check-in work on .ai. Turns get the 429 passed through as it
is, not marked as a lost sign-in. The README says so.

Run on mote (Bun 1.4.2, Node 22, HOME=$(mktemp -d)):
- packages/tabbit: bun test 70 pass, 0 fail; node --test 70 pass, 0 fail.
- bun scripts/check.mjs tabbit: ok.
- Repo-wide bun test: 6797 pass, 20 skip, 0 fail (6817 tests, 492 files).

The new tests use the reporter's literal bodies from #833 (the 401
"invalid bearer" and the 492 gate JSON) against a stubbed fetch, so
nothing reaches the network.
- Against the old src (the new tests kept), 8 of the 9 site tests
  fail on their assertions, and so do both new cookie tests ("not
  signed in to web.tabbit.com"). The one that passes is the .com
  regression test, as it should.

Broken by hand, each change red in exactly the test meant for it:
- (a) no learning when both sites refuse: "a token both sites refuse".
- (b) an unreachable site settles .com: "web.tabbit.ai out of reach".
- (c) no usage probe before the catalog: "an international token's
  model list".
- (d) learning on any non-refused answer: "a 5xx or the catalog
  settles no site".

Not tried:
- a real web.tabbit.ai or web.tabbit.com account;
- a real Tabbit Browser cookie store holding a web.tabbit.ai row (its
  host_key is assumed to be web.tabbit.ai);
- getting past the 492 gate on .ai.
No magpie-side change is needed: magpie has no tabbit mover or min.

Reported-by: Beyfish
This commit is contained in:
yetone
2026-11-07 19:57:13 +08:00
parent 5ed1ac6d3d
commit 50bb3f5ad2
9 changed files with 487 additions and 50 deletions
+15 -1
View File
@@ -43,12 +43,26 @@ Tabbit's sign-in is a `token` cookie: an RS256 JWT issued by
| Method | What it does |
|---|---|
| **Read Tabbit Browser sign-in** (macOS) | Finds the cookie store Tabbit Browser keeps (`~/Library/Application Support/Tabbit Browser/Default/Cookies`), reads the `token` cookie, and decrypts it with the password in the login keychain under `Tabbit Browser Safe Storage`. 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` and read the `token` cookie from the developer tools; paste it whole. |
| **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:** as of 2026-11-07, `web.tabbit.ai`
> answers a turn's `runs` call with `429`, code `492` ("Welcome to Tabbit
> Browser…"), a gate the web app passes from inside the browser (#833).
> Sign-in, the catalog, usage and the check-in work there; turns pass that
> `429` through until the gate is solved.
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.
+3 -2
View File
@@ -1,4 +1,5 @@
// Tabbit (web.tabbit.com) as a magpie provider.
// Tabbit (web.tabbit.com, and web.tabbit.ai for international accounts) as a
// magpie provider.
//
// The shape is the one every magpie provider plugin has — config, auth,
// provider.models — because the work is a plain HTTP conversation with
@@ -483,7 +484,7 @@ function createPlugin() {
callback: async () => {
try {
const sign = desktopSignIn()
return { type: "success", key: sign.key, accountId: sign.userId, metadata: { userId: sign.userId, source: "desktop" } }
return { type: "success", key: sign.key, accountId: sign.userId, metadata: { userId: sign.userId, source: "desktop", site: sign.site } }
} catch (error) {
return { type: "failed", error: String(error?.message ?? error) }
}
+2 -2
View File
@@ -1,7 +1,7 @@
{
"name": "@magpie-community/opencode-tabbit-auth",
"version": "0.1.0",
"description": "Tabbit (web.tabbit.com) as a magpie / OpenCode provider: live model catalog, cookie sign-in, chat completions, cycle usage and the daily check-in",
"version": "0.1.1",
"description": "Tabbit (web.tabbit.com and web.tabbit.ai) as a magpie / OpenCode provider: live model catalog, cookie sign-in, chat completions, cycle usage and the daily check-in",
"type": "module",
"main": "./opencode.mjs",
"exports": {
+150 -37
View File
@@ -1,4 +1,5 @@
// Tabbit's own HTTP API, as the web app (web.tabbit.com) calls it.
// Tabbit's own HTTP API, as the web app calls it: web.tabbit.com for the
// Chinese site, web.tabbit.ai for the international one (see SITES).
//
// Everything here was measured against a live signed-in session:
//
@@ -14,7 +15,52 @@
// `managed` ride along because the app sends them, not because the server
// needs them to authenticate.
export const BASE = "https://web.tabbit.com"
// Tabbit runs two sites with the same API and two account bases. A token
// from one is refused on the other (#833: an international token gets 401
// "invalid bearer" on web.tabbit.com's usage and is accepted on
// web.tabbit.ai), so each account is served by the site its token belongs to.
// BASE comes first and stays the default: a token it accepts never asks the
// other site anything.
export const SITES = ["https://web.tabbit.com", "https://web.tabbit.ai"]
export const BASE = SITES[0]
// siteOfValue reads a site from what an account recorded ("web.tabbit.ai",
// "https://web.tabbit.ai/…"); anything that is not one of SITES is unknown.
export function siteOfValue(value) {
if (typeof value !== "string" || !value.trim()) return null
let host = value.trim()
try {
host = new URL(host.includes("://") ? host : `https://${host}`).host
} catch {
return null
}
return SITES.find((site) => new URL(site).host === host.toLowerCase()) ?? null
}
// learned is the site each token turned out to belong to, for tokens whose
// account didn't record one (a pasted token). It is this process's memory
// only, and capped: a token lives seven days, so a long-running host sees a
// new one each week per account.
const learned = new Map()
const LEARNED_LIMIT = 64
function learn(token, site) {
learned.delete(token)
learned.set(token, site)
while (learned.size > LEARNED_LIMIT) learned.delete(learned.keys().next().value)
}
// siteOf is where a request for these credentials goes: the account's own
// record, else what was learned for the token, else BASE.
export function siteOf(creds) {
return creds?.site || learned.get(creds?.token) || BASE
}
// siteKnown says whether siteOf is settled for these credentials, rather
// than BASE by default.
export function siteKnown(creds) {
return Boolean(creds?.site || learned.has(creds?.token))
}
// A browser User-Agent is what the app sends and what the proxy answers.
// Nothing else is required: the version gate that refuses
@@ -68,7 +114,8 @@ export function credsOf(auth) {
const token = header.match(/(?:^|;\s*)token=([^;]+)/)?.[1]
if (!token) return null
const fromCookie = header.match(/(?:^|;\s*)user_id=([^;]+)/)?.[1] || ""
return { header, token, uid: uid || fromCookie || uidOfClaims(claimsOf(token)) }
const site = siteOfValue(auth?.metadata?.site)
return { header, token, uid: uid || fromCookie || uidOfClaims(claimsOf(token)), ...(site ? { site } : {}) }
}
// claimsOf reads the JWT payload without verifying it: the fields name the
@@ -106,13 +153,13 @@ export function stale(auth, skewMs = 60_000) {
return claims.exp * 1000 - skewMs <= Date.now()
}
function headersFor(creds, extra) {
function headersFor(creds, site, extra) {
return {
cookie: creds.header,
accept: "application/json",
"user-agent": UA,
origin: BASE,
referer: `${BASE}/newtab`,
origin: site,
referer: `${site}/newtab`,
...extra,
}
}
@@ -125,39 +172,95 @@ function safeJSON(text) {
}
}
async function call(creds, path, init = {}, signal, { totalTimeout = true } = {}) {
// refusalOf reads a 401/403 once: Tabbit's code, and whether it is the
// paywall (the account is fine) or the sign-in being refused.
async function refusalOf(res) {
let body = ""
try {
body = await res.text()
} catch {
/* the status is enough */
}
const parsed = safeJSON(body)
// The refusal nests the code two ways: {"detail":{"message","details":{"code"}}}
// on /api/v3, {"code"...} at the top on some routes.
const detail = parsed?.detail ?? parsed?.details ?? parsed
const code = Number(detail?.details?.code ?? detail?.code ?? parsed?.details?.code ?? parsed?.code)
const action = detail?.details?.action ?? detail?.action ?? parsed?.action
// 403 with code 492 is a paywall, not a lost sign-in: the account is
// still signed in, the model just isn't on its plan. Measured with
// Kimi-K3.1-Pro on a free account.
const paywalled = res.status === 403 && code === 492
return { res, body, parsed, detail, code, action, paywalled }
}
const refused = (res) => res.status === 401 || res.status === 403
async function call(creds, path, init = {}, signal, { totalTimeout = true, settles = true } = {}) {
// A streamed turn may run for minutes; Bun's fetch applies this signal to
// reading the body too, so a total timeout would cut a slow answer in half.
// `join` therefore passes its own signal only and lets STREAM_TIMEOUT bound
// the turn; every other call keeps the total timeout.
const bound = totalTimeout
? signal
? AbortSignal.any([signal, AbortSignal.timeout(timeoutMs())])
: AbortSignal.timeout(timeoutMs())
: signal
const res = await fetch(BASE + path, {
...init,
headers: headersFor(creds, init.headers),
...(bound ? { signal: bound } : {}),
redirect: "error",
})
if (res.status === 401 || res.status === 403) {
let body = ""
try {
body = await res.text()
} catch {
/* the status is enough */
const bound = () =>
totalTimeout
? signal
? AbortSignal.any([signal, AbortSignal.timeout(timeoutMs())])
: AbortSignal.timeout(timeoutMs())
: signal
const send = (site) => {
const b = bound()
return fetch(site + path, {
...init,
headers: headersFor(creds, site, init.headers),
...(b ? { signal: b } : {}),
redirect: "error",
})
}
// `settles: false` is for a call that answers any token (the catalog):
// its answer says nothing about which site the token belongs to.
const known = !settles || siteKnown(creds)
let site = siteOf(creds)
let res = await send(site)
let refusal = refused(res) ? await refusalOf(res) : null
// A token whose site isn't known yet and that this site refuses may be the
// other site's: ask it once. Its answer settles the token's site either
// way — accepted there, or refused by both (an expired token, which then
// stays on BASE and is reported as before). A failure to reach the other
// site settles nothing, and the first refusal stands.
if (!known && refusal && !refusal.paywalled) {
let settled = true
for (const other of SITES) {
if (other === site) continue
let again
try {
again = await send(other)
} catch (error) {
if (signal?.aborted) throw error
settled = false
continue
}
if (!refused(again)) {
site = other
res = again
refusal = null
break
}
try {
await again.body?.cancel()
} catch {
/* nothing to release */
}
}
const parsed = safeJSON(body)
// The refusal nests the code two ways: {"detail":{"message","details":{"code"}}}
// on /api/v3, {"code"...} at the top on some routes.
const detail = parsed?.detail ?? parsed?.details ?? parsed
const code = Number(detail?.details?.code ?? detail?.code ?? parsed?.details?.code ?? parsed?.code)
const action = detail?.details?.action ?? detail?.action ?? parsed?.action
// 403 with code 492 is a paywall, not a lost sign-in: the account is
// still signed in, the model just isn't on its plan. Measured with
// Kimi-K3.1-Pro on a free account.
const paywalled = res.status === 403 && code === 492
if (settled) learn(creds.token, refusal ? BASE : site)
} else if (!known && res.ok) {
// Accepted: this is the token's site. A 429 or 5xx settles nothing.
learn(creds.token, site)
}
if (refusal) {
const { body, parsed, detail, code, action, paywalled } = refusal
const error = new TabbitError(
paywalled
? detail?.details?.message || detail?.message || parsed?.message || "This model needs a paid Tabbit plan."
@@ -186,9 +289,19 @@ async function call(creds, path, init = {}, signal, { totalTimeout = true } = {}
// listModels is the live catalog. It answers without a valid token too —
// the same 22 models came back with a deliberately broken cookie — so a
// failure here means the network or the service, never the sign-in.
// failure here means the network or the service, never the sign-in. For the
// same reason it can't tell which site a token belongs to, so a token whose
// site isn't settled yet is first put to a call that checks the sign-in
// (the cycle's usage); the catalog then comes from that token's own site.
export async function listModels(creds, { scene = "chat", signal } = {}) {
const res = await call(creds, `/proxy/v1/model_config/models?a=0&scene=${encodeURIComponent(scene)}`, {}, signal)
if (!siteKnown(creds)) {
try {
await usage(creds, signal)
} catch {
/* the catalog is asked anyway; a refusal shows on the calls that check */
}
}
const res = await call(creds, `/proxy/v1/model_config/models?a=0&scene=${encodeURIComponent(scene)}`, {}, signal, { settles: false })
const body = await res.json()
const models = Array.isArray(body?.models) ? body.models : []
return models.filter((m) => clean(m?.display_name))
@@ -319,4 +432,4 @@ export async function stop(creds, room) {
} catch {
/* stopping is best effort */
}
}
}
+15 -5
View File
@@ -24,7 +24,11 @@ import path from "node:path"
import crypto from "node:crypto"
import { execFileSync } from "node:child_process"
export const HOST = "web.tabbit.com"
// The two sites a Tabbit account can belong to (see SITES in api.mjs), the
// Chinese one first. A browser signed in to either keeps the token under
// that site's host, so the host it was found under names the account's site.
export const HOSTS = ["web.tabbit.com", "web.tabbit.ai"]
export const HOST = HOSTS[0]
const SAFE_STORAGE = "Tabbit Browser Safe Storage"
// profileDirs are the places Tabbit Browser has kept its profile, newest
@@ -132,7 +136,7 @@ function require_node_sqlite() {
//
// `platform` and `tmpParent` are for the tests: the same code path runs with a
// fixture store under a temp parent the test can look into afterwards.
export function desktopSignIn({ dirs = profileDirs(), host = HOST, store, password, tmpParent, platform = process.platform } = {}) {
export function desktopSignIn({ dirs = profileDirs(), hosts = HOSTS, store, password, tmpParent, platform = process.platform } = {}) {
if (platform !== "darwin") {
throw new Error(`reading Tabbit Browser's cookies is macOS-only; on ${platform} paste the token instead`)
}
@@ -141,15 +145,21 @@ export function desktopSignIn({ dirs = profileDirs(), host = HOST, store, passwo
const dir = fs.mkdtempSync(path.join(tmpParent ?? os.tmpdir(), "tabbit-cookies-"))
try {
const copy = copyStore(file, dir)
const rows = readCookies(copy, { host })
let host = hosts[0]
let rows = []
for (const candidate of hosts) {
rows = readCookies(copy, { host: candidate })
host = candidate
if (rows.some((r) => r.name === "token")) break
}
const token = rows.find((r) => r.name === "token")
if (!token) throw new Error(`Tabbit Browser is not signed in to ${host}`)
if (!token) throw new Error(`Tabbit Browser is not signed in to ${hosts.join(" or ")}`)
const secret = password ?? keychainPassword()
const value = token.value?.startsWith("ey") ? token.value : decryptValue(token.encrypted, { password: secret, host })
const uid = rows.find((r) => r.name === "user_id")
const uidValue = uid?.value || (uid?.encrypted ? safeDecrypt(uid.encrypted, secret, host) : "")
const header = [`token=${value}`, uidValue && `user_id=${uidValue}`, uidValue && `SAPISID=${uidValue}`, "managed=tab_browser"].filter(Boolean).join("; ")
return { key: header, userId: uidValue, store: file }
return { key: header, userId: uidValue, store: file, site: `https://${host}` }
} finally {
fs.rmSync(dir, { recursive: true, force: true })
}
+3 -2
View File
@@ -1,7 +1,8 @@
// Turning Tabbit's catalog into the models magpie shows.
//
// The catalog is the one `web.tabbit.com/proxy/v1/model_config/models` gives
// the app. Its fields that decide what an agent may do:
// The catalog is the one `/proxy/v1/model_config/models` gives the app, on
// the account's own site (web.tabbit.com or web.tabbit.ai). Its fields that
// decide what an agent may do:
//
// display_name the id a turn is asked with (selected_model), so it is
// also this provider's model id — nothing is invented
+31
View File
@@ -145,6 +145,37 @@ withCleanup("a failed desktop sign-in leaves no copy either", () => {
assert.deepEqual(fs.readdirSync(parent), [])
})
// An international account's browser keeps the token under web.tabbit.ai,
// sealed with that host's hash (#833).
withCleanup("a browser signed in to web.tabbit.ai signs in there, and says so", () => {
let DatabaseSync
try {
DatabaseSync = globalThis.process.getBuiltinModule("node:sqlite").DatabaseSync
} catch {
return
}
const AI = "web.tabbit.ai"
const root = tmp("tabbit-store-ai-")
const file = path.join(root, "Cookies")
const db = new DatabaseSync(file)
db.exec("create table cookies(host_key text, name text, value text, encrypted_value blob)")
db.prepare("insert into cookies values (?,?,?,?)").run(AI, "token", "", seal("tok-intl", { host: AI }))
db.prepare("insert into cookies values (?,?,?,?)").run(AI, "user_id", "", seal("u-intl", { host: AI }))
db.close()
const sign = desktopSignIn({ store: file, password: PASSWORD, tmpParent: tmp("tabbit-parent-"), platform: "darwin" })
assert.match(sign.key, /^token=tok-intl; user_id=u-intl;/)
assert.equal(sign.userId, "u-intl")
assert.equal(sign.site, "https://web.tabbit.ai")
})
withCleanup("a browser signed in to web.tabbit.com still signs in there", () => {
const file = storeWith("tok-com")
if (!file) return
const sign = desktopSignIn({ store: file, password: PASSWORD, tmpParent: tmp("tabbit-parent-"), platform: "darwin" })
assert.match(sign.key, /token=tok-com/)
assert.equal(sign.site, "https://web.tabbit.com")
})
test("the desktop method is macOS-only, and says so elsewhere", () => {
assert.throws(() => desktopSignIn({ store: "/nonexistent/Cookies", platform: "linux" }), /macOS-only/)
assert.throws(() => desktopSignIn({ store: "/nonexistent/Cookies", platform: "win32" }), /macOS-only/)
+267
View File
@@ -0,0 +1,267 @@
// Which Tabbit site an account is served by (#833): web.tabbit.com for the
// Chinese site, web.tabbit.ai for the international one. A token from one is
// refused on the other, so an account goes to the site its token belongs to.
//
// The refusals and the international gate below are the reporter's own
// answers from #833, byte for byte.
import test from "node:test"
import assert from "node:assert/strict"
import { TabbitPlugin } from "../index.mjs"
// A namespace import, so the behaviour tests still load (and fail on what they
// check) against a build without the site helpers.
import * as api from "../src/api.mjs"
const { credsOf, usage } = api
const COM = "web.tabbit.com"
const AI = "web.tabbit.ai"
// What web.tabbit.com answered an international token (#833).
const INVALID_BEARER = "invalid bearer [REDACTED_TOKEN]"
// What web.tabbit.ai answers a run for a plain cookie-bearing call (#833).
const GATE_492 = '{"message": "Welcome to Tabbit Browser (https://www.tabbit.ai/), where you can use the most comprehensive and advanced models for free.", "code": 492, "action": "", "states": "", "details": ""}'
const frame = (event, data) => `event: ${event}\ndata: ${JSON.stringify(data)}\n\n`
const TURN = [
frame("message_history", { payload: { messages: [{ message_id: "a0", role: "user", content: "hi" }, { message_id: "a1", role: "assistant", content: "" }] } }),
frame("assistant_message_started", { payload: { run_id: "r1", message_id: "a1" } }),
frame("assistant_message_delta", { payload: { chunk_payload: { content: "ok" } } }),
frame("assistant_message_finished", { payload: { message_id: "a1" } }),
frame("run_completed", { payload: { status: "COMPLETED" } }),
].join("")
// Each test has its own token: the site a token turned out to belong to is
// remembered for the process.
let n = 0
function tokenFor(label) {
n += 1
const payload = Buffer.from(JSON.stringify({ sub: `${label}-${n}`, exp: 4102444800 })).toString("base64url")
return `eyJhbGciOiJSUzI1NiJ9.${payload}.sig-${label}-${n}`
}
// tabbit stubs both sites. `accepts` lists the hosts that take the token;
// any other host refuses it the way web.tabbit.com refused it in #833.
function tabbit({ accepts, down = [], runs } = {}) {
const calls = []
const original = globalThis.fetch
globalThis.fetch = async (input, init = {}) => {
const url = new URL(typeof input === "string" ? input : input.url)
const method = (init.method ?? "GET").toUpperCase()
const headers = new Headers(init.headers ?? {})
calls.push({ host: url.host, method, path: url.pathname, origin: headers.get("origin"), referer: headers.get("referer") })
if (down.includes(url.host)) throw new TypeError("fetch failed")
// The catalog answers any token, on both sites (api.mjs says so).
if (url.pathname === "/proxy/v1/model_config/models") {
return Response.json({ models: [{ display_name: url.host === AI ? "AI-Only-Model" : "Com-Only-Model", model_access_type: "free_unlimited" }] })
}
if (!accepts.includes(url.host)) return new Response(INVALID_BEARER, { status: 401 })
if (url.pathname === "/api/commerce/quota/v1/usage") {
return Response.json({ member_level: "standard", usage_percentage: "0%", current_cycle_start: "2026.11.03", current_cycle_end: "2026.11.10" })
}
if (url.pathname === "/api/v3/chat/rooms" && method === "POST") return Response.json({ room_id: "room-1" })
if (url.pathname.endsWith("/runs") && method === "POST") {
if (runs) return runs(url)
return Response.json({ run_id: "run-1" })
}
if (url.pathname.endsWith("/join") && method === "POST") {
return new Response(TURN, { status: 200, headers: { "content-type": "text/event-stream" } })
}
return new Response("not found", { status: 404 })
}
return { calls, restore: () => (globalThis.fetch = original) }
}
const hosts = (calls) => [...new Set(calls.map((c) => c.host))]
async function chatOnce(auth, model = "Default") {
const hooks = await TabbitPlugin()
const loader = await hooks.auth.loader(async () => auth)
return await loader.fetch(`${loader.baseURL}/chat/completions`, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ model, messages: [{ role: "user", content: "hi" }] }),
})
}
test("a pasted international token is served by web.tabbit.ai, and its usage reads", async () => {
const auth = { type: "api", key: tokenFor("intl") }
const { calls, restore } = tabbit({ accepts: [AI] })
try {
const hooks = await TabbitPlugin()
const u = await hooks.auth.usage(async () => auth)
assert.equal(u.error, undefined, `usage failed: ${u.error}`)
assert.equal(u.signIn, undefined)
assert.equal(u.plan, "Tabbit standard")
const answered = calls.filter((c) => c.host === AI)
assert.ok(answered.length > 0, "web.tabbit.ai was never asked")
assert.equal(answered[0].origin, "https://web.tabbit.ai")
assert.equal(answered[0].referer, "https://web.tabbit.ai/newtab")
// Settled: the next calls go straight to web.tabbit.ai.
calls.length = 0
await hooks.auth.usage(async () => auth)
assert.deepEqual(hosts(calls), [AI])
} finally {
restore()
}
})
test("an international token's model list is web.tabbit.ai's catalog", async () => {
const auth = { type: "api", key: tokenFor("intl-models") }
const { restore } = tabbit({ accepts: [AI] })
try {
const hooks = await TabbitPlugin()
const rows = await hooks.provider.models({ models: {} }, { auth })
assert.deepEqual(Object.keys(rows), ["AI-Only-Model"])
} finally {
restore()
}
})
test("an international token's turn goes to web.tabbit.ai, and its 492 gate is not a lost sign-in", async () => {
const auth = { type: "api", key: tokenFor("intl-chat") }
const ok = tabbit({ accepts: [AI] })
try {
const res = await chatOnce(auth)
assert.equal(res.status, 200)
const body = await res.json()
assert.equal(body.choices[0].message.content, "ok")
// web.tabbit.com is asked once, refuses, and every later call is
// web.tabbit.ai's: the run and its stream included.
assert.equal(ok.calls.filter((c) => c.host === COM).length, 1)
const turn = ok.calls.filter((c) => /\/(runs|join)$/.test(c.path))
assert.equal(turn.length, 2)
assert.deepEqual(hosts(turn), [AI])
} finally {
ok.restore()
}
const gated = { type: "api", key: tokenFor("intl-gate") }
const gate = tabbit({ accepts: [AI], runs: () => new Response(GATE_492, { status: 429, headers: { "content-type": "application/json" } }) })
try {
const res = await chatOnce(gated)
assert.equal(res.status, 429)
assert.equal(res.headers.get("x-magpie-sign-in"), null)
assert.match((await res.json()).error.message, /Welcome to Tabbit Browser/)
} finally {
gate.restore()
}
})
test("a web.tabbit.com token never asks web.tabbit.ai anything", async () => {
const auth = { type: "api", key: tokenFor("com") }
const { calls, restore } = tabbit({ accepts: [COM] })
try {
const hooks = await TabbitPlugin()
const u = await hooks.auth.usage(async () => auth)
assert.equal(u.plan, "Tabbit standard")
const rows = await hooks.provider.models({ models: {} }, { auth })
assert.deepEqual(Object.keys(rows), ["Com-Only-Model"])
const res = await chatOnce(auth)
assert.equal(res.status, 200)
assert.deepEqual(hosts(calls), [COM])
assert.equal(calls[0].origin, "https://web.tabbit.com")
} finally {
restore()
}
})
test("a token both sites refuse is a lost sign-in, settled on web.tabbit.com", async () => {
const auth = { type: "api", key: tokenFor("expired") }
const { calls, restore } = tabbit({ accepts: [] })
try {
const first = await chatOnce(auth)
assert.equal(first.status, 401)
assert.equal(first.headers.get("x-magpie-sign-in"), "expired")
assert.deepEqual(hosts(calls).sort(), [AI, COM].sort())
calls.length = 0
const again = await chatOnce(auth)
assert.equal(again.status, 401)
assert.deepEqual(hosts(calls), [COM])
} finally {
restore()
}
})
test("web.tabbit.ai out of reach leaves web.tabbit.com's refusal standing, and settles nothing", async () => {
const auth = { type: "api", key: tokenFor("ai-down") }
const { calls, restore } = tabbit({ accepts: [], down: [AI] })
try {
const first = await chatOnce(auth)
assert.equal(first.status, 401)
assert.equal(first.headers.get("x-magpie-sign-in"), "expired")
calls.length = 0
await chatOnce(auth)
assert.ok(calls.some((c) => c.host === AI), "web.tabbit.ai was not asked again after it was out of reach")
} finally {
restore()
}
})
test("a 5xx or the catalog settles no site", async () => {
const auth = { type: "api", key: tokenFor("intl-5xx") }
const creds = credsOf(auth)
const original = globalThis.fetch
globalThis.fetch = async (input) => {
const url = new URL(typeof input === "string" ? input : input.url)
if (url.pathname === "/proxy/v1/model_config/models") return Response.json({ models: [] })
return new Response("bad gateway", { status: 502 })
}
try {
await assert.rejects(usage(creds), /HTTP 502/)
await api.listModels(creds)
} finally {
globalThis.fetch = original
}
// Once web.tabbit.com refuses it, the token still finds web.tabbit.ai.
const { calls, restore } = tabbit({ accepts: [AI] })
try {
const data = await usage(creds)
assert.equal(data.member_level, "standard")
assert.ok(calls.some((c) => c.host === AI))
} finally {
restore()
}
})
test("an account that recorded its site goes there without asking the other", async () => {
const auth = { type: "oauth", key: `token=${tokenFor("desktop-ai")}; user_id=u-ai`, metadata: { userId: "u-ai", source: "desktop", site: "https://web.tabbit.ai" } }
const { calls, restore } = tabbit({ accepts: [AI] })
try {
const hooks = await TabbitPlugin()
const rows = await hooks.provider.models({ models: {} }, { auth })
assert.deepEqual(Object.keys(rows), ["AI-Only-Model"])
const u = await hooks.auth.usage(async () => auth)
assert.equal(u.plan, "Tabbit standard")
assert.deepEqual(hosts(calls), [AI])
} finally {
restore()
}
})
test("siteOfValue takes only Tabbit's two sites", () => {
assert.equal(api.siteOfValue("web.tabbit.ai"), "https://web.tabbit.ai")
assert.equal(api.siteOfValue("https://web.tabbit.ai/newtab"), "https://web.tabbit.ai")
assert.equal(api.siteOfValue("https://WEB.TABBIT.COM"), "https://web.tabbit.com")
assert.equal(api.siteOfValue("https://evil.example"), null)
assert.equal(api.siteOfValue(""), null)
assert.equal(api.siteOfValue(undefined), null)
const creds = credsOf({ key: tokenFor("odd"), metadata: { site: "https://evil.example" } })
assert.equal(api.siteOf(creds), "https://web.tabbit.com")
})
test("usage on its own settles an international token's site", async () => {
const auth = { type: "api", key: tokenFor("intl-usage") }
const { restore } = tabbit({ accepts: [AI] })
try {
const creds = credsOf(auth)
assert.equal(api.siteOf(creds), "https://web.tabbit.com")
await usage(creds)
assert.equal(api.siteOf(creds), "https://web.tabbit.ai")
} finally {
restore()
}
})
+1 -1
View File
@@ -229,7 +229,7 @@
{ "package": "@magpie-community/opencode-agnes-code-auth", "name": "Agnes Code", "providers": ["agnes-code"], "community": true,
"summary": { "en": "Unofficial Agnes Code desktop: reuse the desktop sign-in for its OpenAI-compatible gateway, with the live model catalog, daily credit check-in and points balance. Desktop decryption is Windows-only; a paste-token method covers the rest. Differs from opencode-agnes-auth (`agnes`), which signs in to Agnes AI international in Chrome and meters that product's plans and USD balance: this one serves the Agnes Code desktop product and its daily credits.", "zh": "非官方 Agnes Code 桌面端:复用桌面端登录态接入其 OpenAI 兼容网关,含实时模型目录、每日积分签到与余额显示。桌面端解密仅限 Windows,其余平台用粘贴 accessToken。与 opencode-agnes-auth(`agnes`)不同:那边在 Chrome 里登录 Agnes AI 国际版、显示该产品的套餐与美元余额;本包服务 Agnes Code 桌面端产品与它的每日积分。" } },
{ "package": "@magpie-community/opencode-tabbit-auth", "name": "Tabbit", "icon": "https://web.tabbit.com/favicon.ico", "providers": ["tabbit"], "community": true,
"summary": { "en": "Unofficial Tabbit (web.tabbit.com) provider: reuse the Tabbit Browser sign-in on this computer to serve its chat models, with the account's live catalog, cycle usage and the daily check-in. No browser automation: a turn is Tabbit's own room → run → event-stream calls. Client tool calls are not available (Tabbit's tools are its own).", "zh": "非官方 Tabbit(web.tabbit.com)插件:复用本机 Tabbit 浏览器的登录态接入它的聊天模型,含账号实时模型目录、周期用量与每日签到。不走浏览器自动化:一轮对话就是 Tabbit 自己的 建房间 → 发起 → 事件流。不支持客户端工具调用(Tabbit 的工具是它自己的)。" } },
"summary": { "en": "Unofficial Tabbit (web.tabbit.com, and web.tabbit.ai for international accounts) provider: reuse the Tabbit Browser sign-in on this computer to serve its chat models, with the account's live catalog, cycle usage and the daily check-in. No browser automation: a turn is Tabbit's own room → run → event-stream calls. Client tool calls are not available (Tabbit's tools are its own).", "zh": "非官方 Tabbit(web.tabbit.com,国际版账号走 web.tabbit.ai)插件:复用本机 Tabbit 浏览器的登录态接入它的聊天模型,含账号实时模型目录、周期用量与每日签到。不走浏览器自动化:一轮对话就是 Tabbit 自己的 建房间 → 发起 → 事件流。不支持客户端工具调用(Tabbit 的工具是它自己的)。" } },
{ "package": "magpie-plugin-codar", "name": "Codar (科搭)", "icon": "https://codar.speedai.com/assets/codar-icon.png", "providers": ["codar"], "community": true,
"summary": { "en": "Codar (科搭), SpeedAI's research desktop app: its 17 models (the auto router plus the DeepSeek, GLM, GPT and Claude families) over OpenAI Chat and Anthropic Messages, with the model list refreshed live from the vendor. Signs in by reading the desktop app's token file on this machine (read-only) or by pasting an access token; the daily check-in reports the claim and carries the next claim time; the card shows general and agent points and any running free-model activity.", "zh": "科搭(Codar,SpeedAI 出品的研究桌面应用):17 个模型(auto 路由 + DeepSeek、GLM、GPT、Claude 各系),走 OpenAI Chat 与 Anthropic Messages,模型列表从厂商实时刷新。登录可读取本机桌面端令牌(只读)或粘贴访问令牌;每日签到报告领取结果并带上下次可领时间;卡片显示通用与 Agent 点数及进行中的免费模型活动。" } },
{"package": "@magpie-community/gateway-agentcompass", "name": "AgentCompass", "kind": "middleware", "community": true, "summary": {"en": "AgentCompass routing for Magpie: picks <model>:<effort> from candidateModels by task intent, Model DNA and session continuity, orders pool seats by subscription quota, and optionally serves /v1/systemone for Routing Groups.", "zh": "AgentCompass 路由插件:按任务意图、模型能力与会话连续性从 candidateModels 选出 <model>:<effort>,按订阅配额排号池席位,并可选作为路由组 /v1/systemone 分类器。"}, "icon": "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NCA2NCIgZmlsbD0ibm9uZSI+PGNpcmNsZSBjeD0iMzIiIGN5PSIzMiIgcj0iMjgiIHN0cm9rZT0iIzNCODJGNiIgc3Ryb2tlLXdpZHRoPSI0IiBmaWxsPSIjMEYxNzJBIi8+PGNpcmNsZSBjeD0iMzIiIGN5PSIzMiIgcj0iMjIiIHN0cm9rZT0iIzYwQTVGQSIgc3Ryb2tlLXdpZHRoPSIxLjUiIHN0cm9rZS1kYXNoYXJyYXk9IjMgMyIvPjxwb2x5Z29uIHBvaW50cz0iMzIsMTIgMzgsMzIgMzIsMjggMjYsMzIiIGZpbGw9IiNFRjQ0NDQiLz48cG9seWdvbiBwb2ludHM9IjMyLDUyIDM4LDMyIDMyLDM2IDI2LDMyIiBmaWxsPSIjRTJFOEYwIi8+PGNpcmNsZSBjeD0iMzIiIGN5PSIzMiIgcj0iMy41IiBmaWxsPSIjRjhGQUZDIi8+PC9zdmc+"},