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
117 lines
5.0 KiB
JavaScript
117 lines
5.0 KiB
JavaScript
// Turning Tabbit's catalog into the models magpie shows.
|
|
//
|
|
// 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
|
|
// supports_images the model can read an image
|
|
// supports_tools the model has Tabbit's *server* tools (browser, search)
|
|
// — not client tools, so `toolcall` stays false
|
|
// support_thinking the model reasons, and the stream carries the thinking
|
|
// model_access_type free_unlimited (Default), free_metered, premium_only
|
|
// display_multiplier Tabbit's credit multiplier, not a USD price
|
|
// hidden the app hides it; so do we
|
|
//
|
|
// Limits are not in the catalog. Tabbit publishes none, so the defaults below
|
|
// apply and are overridable per model: a context the vendor does not state is
|
|
// better shown as a known default than guessed from a description.
|
|
|
|
import { BASE } from "./api.mjs"
|
|
|
|
export const NPM = "@ai-sdk/openai-compatible"
|
|
export const CHAT_BASE = `${BASE}/api/v3/chat`
|
|
|
|
export const DEFAULT_CONTEXT = Number(process.env.TABBIT_CONTEXT || 131072)
|
|
export const DEFAULT_OUTPUT = Number(process.env.TABBIT_OUTPUT || 32768)
|
|
|
|
// The two limits Tabbit implies in a model's own description. Everything
|
|
// else keeps the default; an agent that is sent past a real limit gets
|
|
// Tabbit's own error, which magpie reads as a context overflow.
|
|
const LIMITS = {
|
|
"DeepSeek-V4.1-Flash": { context: 1048576, output: 32768 },
|
|
"DeepSeek-V4-Pro": { context: 1048576, output: 32768 },
|
|
}
|
|
|
|
// A bootstrap list, so the Providers page has something before a sign-in and
|
|
// the check script sees a non-empty config. The live catalog replaces it.
|
|
export const BOOTSTRAP = [
|
|
{ display_name: "Default", supports_images: false, supports_tools: true, support_thinking: true, model_access_type: "free_unlimited", display_multiplier: 0 },
|
|
{ display_name: "DeepSeek-V4.1-Flash", supports_images: true, supports_tools: true, support_thinking: true, model_access_type: "free_metered", display_multiplier: 0.2 },
|
|
{ display_name: "GLM-5.3-Flash", supports_images: true, supports_tools: true, support_thinking: true, model_access_type: "free_metered", display_multiplier: 0.1 },
|
|
{ display_name: "GLM-5.3", supports_images: false, supports_tools: true, support_thinking: true, model_access_type: "free_metered", display_multiplier: 0.6 },
|
|
{ display_name: "Qwen3.8-Max", supports_images: false, supports_tools: true, support_thinking: true, model_access_type: "free_metered", display_multiplier: 0.9 },
|
|
]
|
|
|
|
const clean = (v) => (typeof v === "string" ? v.trim() : "")
|
|
|
|
export function isFree(model) {
|
|
return clean(model?.model_access_type).startsWith("free")
|
|
}
|
|
|
|
export function isPremium(model) {
|
|
return clean(model?.model_access_type) === "premium_only"
|
|
}
|
|
|
|
// modelIdOf is the catalog's display name, verbatim: a turn asked with
|
|
// anything else is refused or answered by a different model.
|
|
export function modelIdOf(model) {
|
|
return clean(model?.display_name)
|
|
}
|
|
|
|
// rowOf is the descriptor both magpie readers take: the config hook reads
|
|
// the top-level fields, the models hook reads `capabilities`.
|
|
export function rowOf(model, { context = DEFAULT_CONTEXT, output = DEFAULT_OUTPUT } = {}) {
|
|
const id = modelIdOf(model)
|
|
if (!id) return null
|
|
const limit = LIMITS[id] ?? { context, output }
|
|
const image = Boolean(model?.supports_images)
|
|
const reasoning = Boolean(model?.support_thinking)
|
|
return {
|
|
id,
|
|
providerID: "tabbit",
|
|
name: id,
|
|
api: { id, url: CHAT_BASE, npm: NPM },
|
|
limit,
|
|
// Tabbit's models all stream and reason; tool calls are Tabbit's own
|
|
// server tools, so a client tool an agent declares cannot be honoured.
|
|
reasoning,
|
|
tool_call: false,
|
|
modalities: { input: image ? ["text", "image"] : ["text"], output: ["text"] },
|
|
capabilities: {
|
|
temperature: true,
|
|
reasoning,
|
|
toolcall: false,
|
|
attachment: false,
|
|
input: { text: true, image, audio: false, video: false, pdf: false },
|
|
output: { text: true, image: false, audio: false, video: false, pdf: false },
|
|
},
|
|
options: {},
|
|
headers: {},
|
|
variants: {},
|
|
status: "active",
|
|
release_date: "",
|
|
}
|
|
}
|
|
|
|
// rowsOf turns a catalog into { id: row }, the shape config and the models
|
|
// hook both return. Hidden rows are dropped, and so are premium-only rows
|
|
// when the caller asks for the free ones.
|
|
export function rowsOf(models, { freeOnly = false, context, output } = {}) {
|
|
const out = {}
|
|
for (const model of Array.isArray(models) ? models : []) {
|
|
if (model?.hidden) continue
|
|
if (freeOnly && !isFree(model)) continue
|
|
const row = rowOf(model, { context, output })
|
|
if (row) out[row.id] = row
|
|
}
|
|
return out
|
|
}
|
|
|
|
// namesOf is only what a turn needs: the display names, in catalog order.
|
|
export function namesOf(models) {
|
|
return (Array.isArray(models) ? models : []).map(modelIdOf).filter(Boolean)
|
|
}
|
|
|
|
export const _internal = { LIMITS } |