This file is the frozen interface between the core and every client module.
Read it before touching anything under clients/.
cmd/ ──┐
internal/ ─┴──► internal/core ◄── clients/<name>
- Nothing under
internal/orcmd/may import aclients/*package. - No
clients/*package may import anotherclients/*package. clients/allis the only file that knows the full client list (blank imports).
Everything a module needs comes from core.Deps. If you find yourself wanting a
new field on Deps, that is a design smell — prefer putting the knob in your own
Deps.Config JSON.
In clients/<name>/<name>.go:
func init() { core.Register("<name>", New) }
func New(deps core.Deps) (core.Client, error) { ... }core.Client:
Name() string
Models(ctx context.Context) ([]core.Model, error)
Chat(ctx context.Context, req *core.ChatRequest) (core.Stream, error)
Status(ctx context.Context) core.Statuscore.Stream:
Recv() (core.Event, error) // io.EOF exactly once at the clean end
Close() error // must be idempotentName()must equal the string passed tocore.Register, and is the routing prefix (zcode/GLM-5.3).req.Modelarrives already stripped of the<client>/prefix. Never re-add or re-strip it.Chatreturnscore.ErrNotConfiguredwhen the install holds no credential for the request at all — the configuration problem the gateway maps to HTTP 503. A pool whose credentials exist but are all parked right now (cooled, credit-exhausted, or parked for this model) is a different answer: returncore.ErrPlatformExhausted, so the router moves on to the next platform without the console telling the operator to fix a configuration that is fine. Every usable account at its in-flight ceiling iscore.ErrBusyinstead (HTTP 429). Returncore.ErrUnsupportedfor a request shape you cannot express upstream → HTTP 400. Any other error → HTTP 502.- Name the credential that served the turn.
req.ServedByis a*stringthe gateway allocates per request; callcore.NoteServedBy(req, id)at the point you pick the account, and it is read exactly once afterChatreturns. You are the only place this is known: the gateway cannot see inside your pool, so without it every success is filed under(unrouted)in the usage ledger and shows a blank account on the console row.- A module that rotates names each attempt — the last writer wins, which is what makes the recorded account the one that actually got through.
- Call it where the account is settled (right after the pick, or where you bind the conversation), not only on success: on failure the gateway prefers the account named by the error itself and falls back to yours when the error names none.
- Write the id the panel's account table uses, and never an account you did not use. Not calling it is allowed and means "unknown" — it is not a lie, and the gateway handles it; naming the wrong account is a lie and is worse than silence.
- Like
ConversationID, this is a gateway↔module channel. Never copy it into the upstream body, and never read it as input.
- Report every upstream failure you absorb.
req.NoteAccountFailure(id, err)is a no-op unless the gateway installed its hook (unit tests and embedders run without one), so call it unconditionally right after an attempt fails and before you rotate. The gateway parks(platform, account, model)for acore.FailureRateLimitedeven when a later account serves the request, which is what makes the panel show the model as limited instead of available. Put the vendor's ownRetry-Afteron thecore.Failure(Failure.RetryAfter); the gateway caps it before parking. A module that never calls this still gets the gateway's terminal-failure fallback, but a 429 it recovered from is then invisible. Recvemitscore.EventDelta/EventToolCall/EventUsage/EventDone/EventError. It returnsio.EOFonce at clean end. Do not returnio.EOFand then keep going.- Emit at most one
EventUsageand at most oneEventDone.EventDone.Finishis an OpenAI finish reason (stop,length,tool_calls,content_filter). Chatmust be safe to call concurrently.Recvon one stream is single-goroutine.- Honour
ctxcancellation: return promptly and close the upstream body. - Never panic. A module that panics takes the whole process down.
All persistent state goes under Deps.DataDir (data/<name>/, already created
with mode 0700) and nowhere else. Use core.WriteJSONAtomic /
core.WriteFileAtomic (0600, tmp+rename) / core.ReadJSON / core.EnsureDir.
Never write outside DataDir. Never read another module's DataDir.
Never log a full token, key or cookie. Use core.MaskSecret.
Deps.Config is the raw JSON of the clients.<name> object from
configs/client2api.json, or nil if absent. You own that schema — define
your own struct, unmarshal it, document it in clients/<name>/README.md.
Prefer auto-discovery of credentials already on this machine (the desktop clients are all installed) with an explicit config override. A module that needs no config at all is the best module.
Every shell invocation must set these (the sandbox denies Go's default cache):
$tools='D:\client2api-lab\_tools'
$env:PATH="$tools\go\bin;$env:PATH"
$env:GOCACHE="$tools\gocache"; $env:GOTMPDIR="$tools\gotmp"; $env:GOMODCACHE="$tools\gomodcache"
$env:GOPROXY='https://goproxy.cn,direct'
Set-Location 'D:\client2api-src'Set-Location is mandatory — go build from anywhere else fails with
cannot find main module.
Then:
go vet ./...
go build ./...
go test ./clients/<name>/... -vDependencies: a module should add nothing beyond the two dependencies the
project already has — github.com/refraction-networking/utls (TLS fingerprints)
and golang.org/x/net (HTTP/2). A module may pull a dependency that only it
needs, but a dependency another module could also need does not belong to a
module: that couples them. If you genuinely need one, add it with go get and
say why in the module's README.
go build -o client2api.exe ./cmd/client2api
.\client2api.exe -config configs/client2api.json
# then
curl.exe -s http://127.0.0.1:8788/v1/models
curl.exe -s http://127.0.0.1:8788/v1/status
curl.exe -s -X POST http://127.0.0.1:8788/v1/chat/completions -H "Content-Type: application/json" -d '{\"model\":\"<name>/<model>\",\"messages\":[{\"role\":\"user\",\"content\":\"say hi\"}],\"stream\":true}'Network access needs the proxy: http://192.168.0.217:18867
(-proxy flag, or HTTPS_PROXY env). Use curl.exe, not
Invoke-WebRequest — the latter is broken in this non-interactive shell.
Each module ships clients/<name>/<name>_test.go with offline unit tests:
- pure functions (encoders, parsers, body builders, SSE frame decoders) — table-driven, using recorded upstream fixtures inline as string literals;
- a fake
http.RoundTripperorhttptest.Serverfor the transport layer; - credential loading from a temp dir.
Tests must pass with no network. Live/credentialed checks go in a separate
*_live_test.go guarded by an env var (e.g. CLIENT2API_LIVE=1) and skipped
by default.
Status() is rendered by the panel. Fill it in honestly:
Ready— true only when a request could plausibly succeed right now.Detail— one human line: account count, mode, last error.Accounts— onecore.AccountStatusper credential, withStateone ofready|cooling|exhausted|invalid|unknown.Models— the model ids you serve (bare names). This list may be cached: the panel calls it on every refresh, so a module that asks its vendor for the catalogue should keep a TTL (see §6,core.ModelRefresher). CachingModelsis allowed; makingStatusexpensive is not.
Status must never block for more than ~1s and must never make a network call
that can hang; it is called on every panel refresh (10s).
Two things a module never has to think about, but should not fight either:
- Every panel response carries a policy. The shell, the JSON API and even the
401s go out with
Content-Security-Policy,X-Content-Type-Options: nosniff,X-Frame-Options: DENY,Referrer-Policy: no-referrer,Cross-Origin-Opener-PolicyandCross-Origin-Resource-Policy: same-origin(internal/panel/security.go). The policy starts fromdefault-src 'none'and names the shell's single inline script by SHA-256 hash rather than by'unsafe-inline'; the hash is computed from the embeddedindex.htmlonce at startup, and if the script block cannot be located the policy degrades to'unsafe-inline'instead of leaving a blank page.connect-src 'self'is what lets the panel call/v1/chat/completionsfrom the browser without CORS — a module must not expect the panel to fetch a third-party origin. - Log lines are channelled, not just stored. The gateway's ring keeps
LogEntry{ts, ch, text}and classifies each line by prefix aschat(| #rows),task(the chore verbs —checkin,activity,streak-bonus,travel,blackcat,lottery,keepalive,balance,school,user-resource, and the panel's ownpanel: …verbs) orsys(everything else). So a module that logs its chores throughdeps.Logfwith one of those verb prefixes gets them filed under 任务 in the panel for free; a line that starts with something else is still readable, just filed under 系统. Note the trailing spaces in the prefix table: they are what keepschecking somethingout ofcheckin.
Status() is read-only. A module that can change its credentials implements one
or more of the interfaces in internal/core/accounts.go in its own package
(conventionally clients/<name>/accounts.go). Nothing else in the tree changes:
the panel type-asserts the registered value, so a module that does not implement
them is simply read-only and no sibling module notices.
| Interface | Methods | What the panel shows |
|---|---|---|
core.AccountManager |
AccountFields, Accounts, AddAccount, RemoveAccount, SetAccountEnabled, TestAccount, RefreshAccount |
Per-client account table, "add account" form, enable/disable, test, refresh |
core.CredentialImporter |
Discover(ctx) ([]DiscoveredCredential, error), Import(ctx, paths []string, all bool) ([]AccountRecord, error) |
Import screen listing what was found on this machine |
core.BundleImporter |
ImportBundle(ctx, name string, data []byte) (BundleImportReport, error) |
「上传导出文件」控件 on the import screen, behind the separate capabilities.import_bundle flag. The panel hands over the raw document and never parses it: the shape belongs to whichever third-party tool produced the dump. Per-row failures go in the report's Errors (one unusable row must not cost the other ninety-nine); a returned error means the document as a whole was unreadable, which the panel reports as 502 |
core.LoginProvider |
StartLogin, PollLogin, CancelLogin |
"Sign in" button that shows a URL (plus a user code when the flow carries one), then polls until the operator finishes |
core.CheckinProvider |
CheckinActions(ctx) []CheckinAction, Checkin(ctx, id, action string) (CheckinResult, error) |
"Check in" button per account, plus "check in all" |
core.ModelRefresher |
RefreshModels(ctx context.Context) ([]Model, error) |
"Refresh" button on the 模型与档位 view, and an upstream-vs-fallback marker per model row |
core.ConversationBinder |
BindConversation(conversationKey, accountID string), UnbindConversation(conversationKey string) bool, ConversationAccount(conversationKey, model string) (string, bool) |
The 对话测试 view's account picker, via GET/POST …/clients/<name>/conversations and POST …/conversations/unbind. It is also the routing contract the module keeps to itself; core.AsConversationBinder is how a caller discovers it. Modules without it report capabilities.conversations = false and answer 501 |
core.TaskProvider |
Tasks(ctx, accountID string) ([]TaskInfo, error), RunTask(ctx, accountID, code string) (TaskResult, error) |
任务中心 → 任务看板: the vendor's chore list with progress, one run button per automatable row, and each row's last outcome |
core.TaskAccepter |
AcceptTasks(ctx, accountID string, codes []string) error |
任务看板每行的「接受」按钮(把任务标记为已接) |
core.BulkTaskAccepter |
AcceptAllTasks(ctx, accountID string) (BulkAccept, error) |
「全部接受」按钮,回答 {accepted, failed, message} |
core.TaskClaimer |
ClaimTask(ctx, accountID, code string) (TaskClaim, error) |
「领取」按钮;零增量算成功(幂等),不是错误 |
core.TaskAutoRunner |
RunTaskAuto(ctx, accountID, code string) (AutoTaskResult, error) |
「自动完成」按钮 + 进度回读(progress_before/after、claimable、claimed、claim_error) |
core.Reviver |
ReviveAccount(ctx, id string) error |
账号行的「恢复」按钮:清掉该账号在本进程内的全部惩罚(冷却/熔断/停用),让池子立刻重新尝试 |
core.BalanceProvider |
AccountBalance(ctx, id string, soon time.Duration) (Balance, error) |
账号行的「余额」按钮,外加「即将到期」桶(soon 窗口内会过期的额度) |
core.PackageProvider |
AccountPackages(ctx, id string) (PackageReport, error) |
「积分构成」视图:逐账号的额度分片(remain/size/expires_at),失败是行级错误 |
core.VoucherProvider |
AccountVouchers(ctx, id string) ([]Voucher, error) |
成长任务队列里的券码列表(券码原样展示、可复制) |
core.HealthProvider |
Health() Health |
状态页每个客户端的 health 块:servable(现在能不能服务)、ready/cooling/disabled/total 计数、realms、以及不能服务时的 note 原因 |
core.PoolStatsReporter |
PoolStats() PoolStats |
状态页每个客户端的 pool 块:in_flight、in_flight_full、sticky_sessions(面板的「N 个账号在途占满」与「粘性会话」tile 读的就是它) |
core.HintProvider |
Hint(kind FailureKind, message string, ctx HintContext) string |
上游失败时 error.gateway_hint 的文案。网关先问模块、再回落 internal/hint 的共享规则表:返回 "" 表示「我这条没话说」,不是终判。模块自己的业务码(如 workbuddy 的 11133/11135 图片族)只有模块能解释,所以这条链路是模块专有知识的唯一出口 |
core.TranscriptionProvider is the one optional interface that does not
hang off the panel — it teaches the gateway a new inbound endpoint:
TranscriptionModels(ctx context.Context) []Model
Transcribe(ctx context.Context, req *TranscriptionRequest) (TranscriptionResult, error)A module that implements it (embedding core.Client) is reachable through
POST /v1/audio/transcriptions and has its speech models listed by
GET /v1/models with extra.kind = "transcription". The speech catalogue is
deliberately not Client.Models(): those ids must never enter the chat
routing catalogue, Auto/<model> aggregation or the account pool's model
accounting. Return core.ErrInvalidAudio (400), core.ErrNoSpeech (422),
core.ErrNotConfigured (503) or a *core.Failure, exactly as the chat path
does; the gateway owns the HTTP mapping. Only clients/doubaoime implements it
today. CapabilitiesOf also publishes transcription and the bare
transcription_models; the panel prefixes each model with the current platform
name and shows the callable address in the account pool, including when the
module has no accounts to list.
Every row Accounts() returns is rendered with 删除 and 停用 buttons, and those
buttons call RemoveAccount / SetAccountEnabled unconditionally. So a module
must list only records those two can actually act on: an endpoint or credential
the module merely resolves is configuration, not an account. clients/tabbit
used to append locate()'s result as a managed:false row, which on a fresh
install meant the built-in http://127.0.0.1:50124 default sat in the pool as an
invalid, undeletable row — the only two buttons it had could do nothing but fail
(RemoveAccount answered "endpoint … was not added through the panel; nothing to
remove").
Do not over-correct, though: a real credential found on this machine is not
that case and must stay listed. trae marks those managed:false and still lists
them, refusing only 删除 ("account … was not added through the panel; disable it
instead") while SetAccountEnabled genuinely suppresses them — the disable
button works, so the row is honest.
Nothing is hidden by dropping a resolved endpoint from the table; it moves to the
status surface. tabbit reports the effective sidecar URL and why, in
Status().Detail ("no sidecar configured and nothing listening on <url>
(<err>)"), which both /v1/status and the config page show.
TaskProvider.RunTask is the vendor's "make progress happen". The four verbs
above are the reference's separate operations, and they stay separate because
the operator needs to retry exactly one of them: a chore whose progress is
complete but whose reward failed must be claimable on its own, without running
the chore a second time (which some vendors count as a separate attempt).
Rules:
- A chore you cannot automate is an error naming the reason, not a silent
OK:false— the panel answers501with your message, which is how it tells "go do this in the official client" apart from "the vendor refused". If the chore list carries a per-task "automatable" flag, report it there too (TaskInfo.Auto). - Collecting a reward that was already collected is success. Answer with
TaskClaim.AlreadyClaimed(or zero credit and zero energy); the panel then says "该奖励此前已领取" instead of showing a zero-credit success or a failure. - You do not need to lock anything. The panel answers
409while one task action for that account is in flight, so two rounds can never overlap; a module that also locks is free to, but must not deadlock behind the panel's lock. RunTaskAutoreports the read-back, not just success:ProgressBefore,ProgressAfterandClaimableare what the operator judges the run by, andClaimErroris how you say "the chore passed, the reward did not" so the panel can offer the claim button again. The amounts go on the embeddedTaskResult.Credit/Energy—AutoTaskResultdeliberately does not redeclare them (an outer field of the same name would shadow the embedded one).
These three are the reference's 积分构成 view and its account-row balance button. They are opt-in one by one because a vendor can genuinely have a pooled balance with no tranches, or tranches with nothing else to say.
Balancehas no JSON tags — the panel owns the wire shape ({ok, credits, credits_total, expiring?, earliest_at?, earliest_remaining?}). Fill the expiring buckets only whensoon > 0;soon == 0means the operator does not want that bucket, not "expire now".- A vendor refusal here is an error: the panel answers
502rather than drawing a zero balance, because a wrong number on a credit screen is worse than no screen. - Voucher
Codevalues are not redacted on the way out: the redemption code is the entire payload of that view. Everything else that quotes a vendor string (rowerror,message) still goes throughcore.Redact.
Models() answers "what can this module serve" and is allowed to be a static
list. ModelRefresher is how a module says "I can go ask the vendor right now":
Models()may serve from a cache (a TTL of a few minutes is the norm) because the panel calls it on every refresh.RefreshModels()must bypass that cache — it exists precisely to force a re-read.- A failed refresh must not empty the catalogue. Return the last known-good list alongside the error. The panel renders the list and marks the rows as fallback; a picker that goes blank because the vendor hiccupped is worse than a stale one.
- If no credential is available at all, return the configured/built-in list with a nil error and make no request — and do not count that as an attempt, so the next refresh after a sign-in can succeed immediately instead of waiting out the TTL.
GET /panel/api/modelsreportscan_refreshper module fromcore.CapabilitiesOf, so a module without this interface is never shown a button that lies.POST /panel/api/models/refreshcallsRefreshModelsonly on modules that implement it andModelson the rest.- A claimed output ceiling is not a measured one. Whatever a module puts in
core.Model.Extraasmax_output_tokensis the vendor's claim; the panel also reads an optionaldata/output_probes.json(written by thecmd/probetool, not by any module) and annotates the row when a probe found the real ceiling lower. The two are shown side by side rather than merged, so a module never has to reconcile them and a missing probe file simply means no annotation.GET /panel/api/model_probesserves that file as-is; see the README's Probing output ceilings for the verdict vocabulary.
Chat may route a request to any account in its pool, and a module whose vendor
bills a per-account prompt cache (workbuddy salts prompt_cache_key per
credential) pays for a conversation that wanders between accounts: the ~8k-token
prefix is re-billed on every cache miss. core.ConversationBinder is how a
module says "this conversation is pinned to the account that already served it".
// Implemented in the module's own package, e.g. clients/<name>/affinity.go.
func (c *Client) BindConversation(conversationKey, accountID string)
func (c *Client) UnbindConversation(conversationKey string) bool
func (c *Client) ConversationAccount(conversationKey, model string) (string, bool)Rules:
- Opt-in, and nil-safe.
internal/core/affinity.goprovides the mechanism (core.NewAffinity(ttl),Bind/Resolve/Unbind/Count/GC/StartGC/StopGC). Every exported method on a nil*Affinityis a no-op or reports "nothing bound", so a module can hold anilfield and call it freely. A module that ignores the interface entirely routes exactly as it did before — no sibling module notices, and no core edit is required to adopt it. - Off is not a zero window.
session_sticky.enabled(default true) is a knob separate from the TTL, and turning it off must skipBind/Resolveentirely rather than shorten the window: the reference builds no session router at all when it is false, so every request selects an account from scratch.core.LiveSettings.AffinityEnabledcarries it as a pointer for the same reason as the ceilings —nilmeans "the file said nothing" and leaves the current state alone. Disabling also drops the bindings already held, because they were chosen under a policy that is no longer in force; a TTL of0is not the way to disable stickiness, andSetTTLresolves a non-positive value back to the 30m default instead of to "expire immediately". - The key comes from the request, never from a counter. Use
core.ConversationKeyOf(req): the conversation id the gateway already resolved —metadata.conversation_id→metadata.conversationId→ top-levelconversation_id→ top-levelconversationId— and otherwise the raw option spellingsconversation_id→conversationId→prompt_cache_key→ trimmedreq.User. Prefer it overcore.ConversationKey(req.Options, req.User): a client that follows the OpenAI convention carries its id inmetadata, where the option map cannot see it, so keying off options alone silently drops stickiness for exactly the clients that are most explicit about their conversations. A caller that supplies nothing yields"", which must turn stickiness off for that request rather than inventing a shared key. - Content-derived keys are opt-in, and they are namespaced. A client that
sends no conversation id and no
userstill deserves stickiness: without it every turn rotates accounts and re-bills the whole prefix, because the cache the previous account had already warmed is unreachable.core.DeriveConversationKey(msgs)is that fallback — it hashes the system prompt plus the first user turn (sha256(system + "\x00" + firstUser)[:16]) and returns the digest under thed-prefix, which keeps it from ever colliding with an id a client really sent. Only those two turns go in: a multi-turn request appends history every turn, so a whole-transcript hash would move each turn and be worse than no stickiness at all. Non-text parts contribute[type]rather than their content, so an image whose signed URL is re-minted per turn does not move the key, while "no image" and "one image" still differ — and a first turn that is only an image still derives. It is a separate call, deliberately not folded intoConversationKeyOf: tabbit and qwenwork pin "a request that names no conversation leaves the table empty and rotates through the pool", and whether an unattributed request should stick is a per-module decision.clients/workbuddyis the one module that opts in (the reference itself is workbuddy-only), and even there every explicit spelling —req.ConversationID, the option map,meta.ConversationID— wins over the derived key. - Stickiness yields to health, always.
ConversationAccounttakes the model as well as the key so the query can answer "not this account" when the bound account is parked (cooling, exhausted, invalid, or model-cooled for this model). A dead binding is dropped, not remembered: the caller picks normally and re-binds. Blocking a request, or serving a parked account to honour a binding, is a bug in both directions. - Bind at pick time, not after success. Two concurrent requests for a brand new conversation must agree on one account instead of racing onto two and splitting the cache. Re-binding an existing key is an overwrite.
- Bindings expire. The default TTL is 30 minutes of idle time
(
core.DefaultAffinityTTL) andStartGCsweeps them everycore.DefaultAffinityGCInterval(5 minutes), so the table cannot grow with conversations nobody asks about any more. - Bindings are process state, not credentials. The table holds one opaque account id per conversation key and is rebuilt after a restart. Nothing in it may be written to a state file or rendered in the panel.
The account a Chat picks is module policy, not a contract — but two properties
are expected of any pool:
- Never turn rotation into a tight retry loop. Rotation is pacing-sensitive:
a sub-second burst across credentials is what gets a pool flagged. Honour
core.BackoffFrom(jittered, capped) between attempts. - A per-model park must stay runtime-only and must be swept. Losing one model on one credential is not losing the credential. Park the model, not the account, and drop lapsed parks on the pick path so the map cannot grow with every model an account ever touched.
CheckinProvider is how a module says "this platform hands out a daily
reward and here is how to claim it". The panel draws one button per
CheckinAction, so an action list of two (workbuddy: daily-checkin for
CN, daily-activity for the international realm) becomes two buttons rather
than one button that guesses.
Rules:
- Advertise only what exists.
CheckinActionsmust returnnilwhen the module has no claimable reward, or when no configured account could claim one.core.CapabilitiesOfturns a non-empty list intocheckin: true; an empty list means the panel shows no button at all. Do not invent an endpoint because a sibling client has one — of the fourteen shipped modules only workbuddy (CNPOST /v2/billing/meter/daily-checkin, intl daily-activity conversation), trae (POST api.trae.cn/trae/api/v2/ug/checkin_credits/statusthen/claim), zcode (zcode-plan/billing/previewthen/claim, one action namedclaim), minimaxcode (GET /minimax-cloud/api/v1/signin/statusthenPOST …/signin/claim, one action nameddaily-signin), qwenwork (GET /sash/api/v1/me/daily-check-in/statusthen/claim, one action nameddaily), raccoon (POST /api/web/desktop/v1/login/points/grant, one action namedlogin-points— that desktop login grant EXTENDS the day's 300 credits rather than minting them: the 00:00 issuance expires the same day and the grant pushes the expiry to 7 days. The vendor grants it to its own desktop app alone, so a gateway call is always answeredgranted:false. The module resolves it againstGET /api/web/points/v1/bills: adaily_grantfor today that expires beyond today is a real "already claimed" success; anything else — including an unreadable ledger — is a settledskipped("unavailable — claim it from the desktop client"), so the panel greys the row for the rest of the Shanghai day), lobsterai, codearts and loomy have a real one. kimi, tabbit, openrouter and opencode have none. A module whose action is blocked by a vendor control it cannot satisfy still advertises the action and reports the block honestly — zcode's claim is captcha-gated ahead of every other check, so it fails with a message namingcaptcha_commandrather than pretending the feature is absent. - Two bits, two questions.
core.Capabilities.Checkinis the static bit ("this module implementsCheckinProvider") and drives the capability matrix, the bulk routes and the scheduler's scan.core.Capabilities.CheckinReadyis the live bit (len(Actions) > 0) and is the only thing the account row's button reads. Collapsing the two is the defect the split exists to prevent: a module whose accounts are all expired (minimaxcode's imported store) or absent (raccoonwith an empty pool) keeps its ✓ in the matrix — it really does implement check-in — while offering no click that could only fail.internal/core/capabilities_test.gopins the split. - "Already claimed today" is success, not failure. Report
CheckinResult{OK: true}withData["already_done"] = true(trae reads thechecked_inboolean, workbuddy accepts upstream code10001). The operator asked "is today's reward in hand?" — the answer is yes. - Persist the timestamp. If you track "done today" locally, write it into
your own state file so it survives a restart, and compare only the date
prefix (
2006-01-02) — seeclients/workbuddy/auth.go'sdidToday. - Gate on the realm. A CN-only action offered for an international account
must return
OK: falsewith an explanatoryErrorwithout sending a request; a wrong-realm call can burn the account's own rate limit. - Never leak the credential. Pass
Error,Messageand every string inDatathroughcore.Redact, exactly as forTestAccount.
TaskProvider is how a module exposes the vendor's growth centre — the daily
chores the official client performs for the user (send five messages, adopt the
mascot, click through a template) — as something the panel can drive. Core knows
only the shape; every vendor specific lives in the module, so two modules may
disagree about what a task even is.
Surface:
| Route | Meaning |
|---|---|
GET <base>/tasks?account=<id> |
the chore list + this client's recent runs |
POST <base>/tasks/<code>/run |
start one; body {"account":"…"}, optional |
GET <base>/tasks/runs/<id> |
poll one run |
Rules:
- A run is asynchronous and the panel enforces it.
POST …/runanswers202with a run id before the chore starts. The run executes on a context with a 45-minute deadline that is deliberately not derived from the request — the response is written long before the chore ends, sor.Context()would cancel a run the operator just asked for the moment they changed view. Do not try to makeRunTasksynchronous; some chores sleep ~45 s between upstream events and a couple of dozen of them are queued behind one button. - A vendor refusal is a result, not an error. "Already claimed", "prerequisite
not met", "anti-cheat rolled the progress back" are all real answers: return
TaskResult{OK: false, Error: "…"}. Reserve a non-nil error for the attempt could not be made at all — no credential, transport failure. The panel journals both, but only an error means "we never asked". Auto: falseis a legitimate answer. Some chores genuinely need a human: a real connector authorisation, a captcha, an actual donation. Say so inNoterather than offering a button that cannot work. The panel renders such a row read-only instead of hiding it, because the operator still wants to see the progress.- Advertise only what you can do.
Tasksmust return an empty slice (nil error) when there is nothing to show, and must not mutate upstream state — it is called on a timer.core.CapabilitiesOfturns the interface intotasks: true; the board is only drawn for modules that implement it. - Pacing is shared, but the module owns the vendor timing. The panel runs
all chores for one account strictly serially and never overlaps two vendor
calls for the same credential. A module whose chores need a visible human
cadence sets
core.Batch.TaskGap; the scheduler and the panel'srun_queue/batch paths apply it after one chore finishes and add ±20% jitter. Any spacing that is specific to one upstream call (the reference uses 45 s ± 10 s jitter between chat events) still belongs insideRunTask;TaskGapis the account-level quiet period between chores. - Never leak the credential.
Title,Desc,NoteandGroupare upstream strings: the panel passes them throughcore.Redact, and a module that puts a token in a task title would defeat that. Do not.
LoginProvider is how a module signs an operator in without asking them to
install a CLI. The panel calls StartLogin, shows LoginState.URL (and
LoginState.Code when the flow carries a user code) as something the operator
opens in a browser, then polls PollLogin(session_id) on a timer until the
state turns terminal.
Rules:
- Prefer the web/HTTP flow; make the CLI a fallback. Every shipped module
that has a sign-in at all signs in over HTTP: kimi uses the RFC 8628 device
grant against
https://auth.kimi.com, trae opens a loopback redirect on127.0.0.1and catches the callback, zcode pollsPOST {api}/oauth/cli/init→GET …/oauth/cli/poll/{flow_id}, workbuddy polls/v2/plugin/auth/state→/token, qwenwork uses a PKCE device flow. A module whose only route is shelling out to a vendor CLI must say so inStatus().Detailand keep the CLI path behind the HTTP one — an operator who clicked "Sign in" should not be told to go install a binary if the vendor offers a URL. statemust start non-empty.LoginState.Stateis the session's gate: every transition (pending → success|failed|cancelled) is a no-op while the state is"". Build the session withState: core.LoginPendingin the struct literal, or normalise""to pending in the snapshot you return. Getting this wrong makes the callback answer "session is no longer active" for every login and swallows every outcome.- Pending is not an error.
PollLoginreturns(LoginState{State: pending}, nil)while the operator is still in the browser. Reserve a non-nil error for a programming mistake (unknown session id, empty id). A vendor outage, a 5xx or a transport failure is a pending state with a message, so a retry can still succeed. - A failed start is a state, not an error. If the device-authorisation call
fails outright, return
LoginFailedwith the reason scrubbed intoMessage. "No network" and "the client id was retired" are facts for the operator, not Go errors. - Honour the vendor's polling interval. RFC 8628's
slow_downmeans addintervalseconds (kimi adds 5s) and say so in the message. Cache the next allowed poll time and answerpendinglocally without a request when the panel polls faster than the vendor allows — the panel's timer is not the vendor's rate limit. - A sign-in token is not an account credential. The access token an OAuth
flow returns is short-lived and was never issued for API use. Store it only
if the module is going to use it as a session token; never persist it as
a durable account entry. If the post-login exchange (access → API key) fails,
report
LoginFailed— do not fall back to storing the sign-in token, which expires silently and hides the real error. The exception is a vendor that returns only a plan JWT and no access token: that JWT is the issued credential and belongs in the store. - Keep the token inside
DataDir.LoginProviderwrites its own state file in the module's data directory. Writing into a vendor CLI's credential store (~/.kimi-code/credentials/,%APPDATA%\…) is out of bounds: it makes the module a co-owner of another program's login state. - Scrub every message. Poll responses echo request material back in error
text. Pass
Messageand any error string throughcore.Redact— and, where the module has its ownscrubSecretshelper, through the live session secrets too (zcode accumulates the poll token, then the access token). - Say when there is no sign-in. A module that cannot sign in must not pretend
it can: implement no
LoginProvider(so the panel shows no button) and answerPOST /loginwith a plain refusal such as{"error":"<module> has no interactive login"}. Every module here now has one — tabbit's is a browser hand-off with two real paths, because the vendor session can only be created by a browser and the login URL only opens inside the Tabbit browser:clients/tabbit/login.gopoints the operator at 导入凭据 (read thetokencookie out of the running browser into aweb-tokenaccount) and, failing that, at the sidecar, whose model list — not/health, which answers even when nobody is signed in — is the verdict. The rule is kept for the next module, and for a flow that can only be a CLI step: describe the step inStatus().Detailrather than exposing aStartLoginthat always fails.
Rules that apply to all optional interfaces:
- Implement only what you can actually do.
core.CapabilitiesOfderives the advertised capabilities from type assertions, so declaring an interface you cannot honour shows the operator a button that lies. Say why inStatus().Detailinstead — e.g. a module whose vendor offers no HTTP sign-in at all should describe the manual step it needs rather than exposing aStartLoginthat cannot succeed. - A refusal is a result, not an error.
TestAccounton a credential the upstream rejects returnsTestResult{OK: false, Error: "…"}with anilerror. Return a Go error only for a programming mistake, such as an unknown id. - Never write to the main config. Panel-side state goes in the module's own
DataDir. Theclients.<name>block ofconfigs/client2api.jsonis operator-owned and the panel must not edit it. - Never return a secret.
AccountRecord.Fieldsis rendered in a browser: no tokens, no token prefixes, no key fingerprints that would help an attacker. Pass any upstream text throughcore.Redactbefore putting it inNoteorTestResult.Error. - A disabled account must survive a restart. Whatever "disable" means for your credential model, it has to persist across process restarts — a token pool can carry a flag in its own state file, a file-per-account module can rename the file.
- Adding a panel surface needs no core edit. If you find yourself editing
internal/or anotherclients/package, the module boundary has been violated — fix the module, not the core. - Say when a credential is dead instead of making the panel guess. If the
pool can tell that the vendor rejected the token itself — as opposed to a
quota cooldown or an upstream 5xx — set
AccountRecord.Fields["relogin"] = true. The panel reads it inneedsRelogin()(internal/panel/index.html) and renders that row's 「重登」 button, which re-runs the vendor's own login in place instead of only clearing the cooldown. Without it the operator is left with the 「恢复」 path, which cannot bring back a credential the vendor has already revoked. trae is the reference implementation (clients/trae/accounts.go,credentialDead).
Recorded here because "the interface exists" and "a module implements it" are
different facts, and the panel shows a button for the second one, not the first.
✓ means a module really implements the interface (with the file that proves
it); — means it does not, and the row says why that is the right answer rather
than a gap waiting to be filled. See internal/core/capabilities_test.go and each
module's accounts.go for the assertions that derive core.Capabilities.
| Mechanism (interface) | workbuddy | trae | qwenwork | zcode | kimi | tabbit | minimaxcode |
|---|---|---|---|---|---|---|---|
TaskProvider (board + RunTask) |
✓ clients/workbuddy/tasks.go:1860 |
— | — | ✓ clients/zcode/tasks.go:153 |
— | — | ✓ clients/minimaxcode/tasks.go:80 |
BatchPlanner (scheduled batches) |
✓ clients/workbuddy/batches.go (the reference's six names) |
— | — | ✓ clients/zcode/tasks.go:67 (one checkin batch) |
— | — | ✓ clients/minimaxcode/tasks.go:39 (one checkin batch) |
TaskAccepter / BulkTaskAccepter / TaskClaimer / TaskAutoRunner |
✓ clients/workbuddy/panel_tasks.go |
— | — | — | — | — | — |
BalanceProvider / PackageProvider / VoucherProvider |
✓ clients/workbuddy/panel_quota.go |
— | — | ✓ balance + packages clients/zcode/claim.go (no vouchers) |
— | — | ✓ balance + packages clients/minimaxcode/signin.go:600, :642 (no vouchers) |
Degrader (degraded prompt) |
✓ clients/workbuddy/prompt.go:146 |
— | — | — | — | — | — |
LiveReloader (prompt, scrubber, in-flight ceilings, stickiness + session switch) |
✓ clients/workbuddy/prompt.go:70 |
✓ clients/trae/affinity.go:121 |
✓ clients/qwenwork/affinity.go:171 |
✓ clients/zcode/affinity.go:138 |
✓ clients/kimi/affinity.go:113 |
✓ clients/tabbit/affinity.go:271 |
✓ clients/minimaxcode/affinity.go:177 |
HealthProvider / PoolStatsReporter |
✓ clients/workbuddy/health.go |
— | — | — | — | ✓ clients/tabbit/health.go |
— |
HintProvider (module-owned error advice) |
✓ clients/workbuddy/hint.go (11133/11135 image family + the vendor ErrKind table) |
— | — | — | — | — | — |
In-flight ceiling (pool.max_in_flight*) |
✓ honoured | — (trae has no WAF 403 family to hold back) | — | — | — | — | — |
CheckinProvider |
✓ clients/workbuddy/checkin.go:58, :94 |
✓ clients/trae/checkin.go:119, :137 (pinned :253) |
✓ clients/qwenwork/checkin.go:159, :452 (one action, daily) |
✓ clients/zcode/claim.go (one action, claim; captcha-gated) |
— | — | ✓ clients/minimaxcode/signin.go:454, :473 (one action, daily-signin) |
Reviver |
✓ | ✓ | ✓ | ✓ | ✓ | — | — |
ConversationBinder (affinity) |
✓ clients/workbuddy/affinity.go:36 |
✓ clients/trae/affinity.go:40 |
✓ clients/qwenwork/affinity.go:88 |
✓ clients/zcode/affinity.go:49 |
✓ clients/kimi/affinity.go:68 |
✓ clients/tabbit/affinity.go:133 |
✓ clients/minimaxcode/affinity.go:49 |
ModelRefresher |
✓ workbuddy.go:413 |
✓ trae.go:177 |
✓ qwenwork.go:192 |
✓ models.go:199 |
✓ models.go:52 |
✓ tabbit.go:99 |
✓ minimaxcode.go:139 (re-reads the local config.yaml; there is no catalogue endpoint) |
CredentialImporter |
✓ accounts.go:33 |
✓ accounts.go:41 |
— | ✓ accounts.go:46 |
✓ accounts.go:58 |
✓ accounts.go:46 |
✓ accounts.go:537 |
BundleImporter (uploaded export file) |
✓ clients/workbuddy/cockpit.go (the reference's cockpit JSON array) |
— | — | — | — | — | — |
LoginProvider |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ (browser hand-off) | ✓ clients/minimaxcode/login.go (RFC 8628 device code; the GUI is not required) |
Static modelmeta table |
33 entries (27 verbatim + 6 effort-only) | — | — | — | 0 entries | 4 entries | — (catalogue comes from the desktop client's config.yaml) |
| Persisted pool/penalty state | cache/pool.json (unhealthy only) |
invalid never persisted | CooldownUntil/Disabled + state.json |
accounts.json fields |
health + enabled maps |
none | accounts.json (tombstones only) |
The eight modules added later are recorded the other way round — one row per module — because fourteen prose columns would be unreadable. A bare name means the interface is implemented in that file; "absent" is a design answer, not a gap, and each module's README gives the reason.
| module | implements | deliberately absent |
|---|---|---|
cline |
AccountManager accounts.go:58; CredentialImporter :497; LoginProvider :371; BalanceProvider :299; Reviver :206; ModelRefresher models.go:534; ModelLimitsProvider models.go:625 |
TaskProvider/BatchPlanner, CheckinProvider, ConversationBinder (and therefore LiveReloader), HintProvider, Degrader, HealthProvider/PoolStatsReporter, PackageProvider/VoucherProvider, BundleImporter, RealmLoginProvider, CaptchaProvider |
lobsterai |
AccountManager accounts.go:51; CredentialImporter :332; BundleImporter :463; LoginProvider login.go:57; BalanceProvider balance.go:30; CheckinProvider checkin.go:22; PoolStatsReporter lobsterai.go:333; HealthProvider health.go:18; ModelRefresher lobsterai.go:185 |
Reviver (a refresh here is unconditional), ModelLimitsProvider (the vendor publishes no output budget, and the interface forbids fetching), TaskProvider/BatchPlanner, ConversationBinder, HintProvider, Degrader, PackageProvider/VoucherProvider, RealmLoginProvider, CaptchaProvider |
codearts |
AccountManager panel.go:27; LoginProvider :412; CheckinProvider credits.go:64; BalanceProvider credits.go:360; Reviver codearts.go:176; HintProvider codearts.go:184; ModelRefresher models.go:466; ModelLimitsProvider models.go:501; PoolStatsReporter health.go:61; HealthProvider health.go:23 |
CredentialImporter (the IDE plugin keeps no discoverable credential file), BundleImporter, RealmLoginProvider (one realm), CaptchaProvider (Huawei's own portal handles the challenge), TaskProvider/BatchPlanner (the vendor has no task API), Degrader, PackageProvider/VoucherProvider, ConversationBinder |
loomy |
AccountManager accounts.go:454; Reviver :573; BalanceProvider quota.go:177; PackageProvider quota.go:210; CheckinProvider quota.go:263; TaskProvider onboarding.go:232, :310; BatchPlanner batches.go:10 (keepalive session heartbeat plus the growth onboarding batch); PhoneCodeLoginProvider phonecode.go (operator-owned phone, manual SMS code); ModelRefresher loomy.go:183 |
LoginProvider (URL-and-poll cannot carry an SMS code; the phone-code flow has its own two-step interface), CredentialImporter/BundleImporter, CaptchaProvider (none needed), ConversationBinder, HintProvider, Degrader, HealthProvider/PoolStatsReporter, VoucherProvider |
raccoon |
AccountManager accounts.go:38; CredentialImporter :210; LoginProvider login.go:214 (loopback QR/SMS page, stdlib QR in qr.go); Reviver :123; BalanceProvider balance.go:46; PackageProvider balance.go:67; CheckinProvider checkin.go:60, :155 (one action, login-points — the desktop login grant, which claims the daily 300 credits); ModelRefresher raccoon.go:156; ModelLimitsProvider raccoon.go:285 |
RealmLoginProvider (a single sign-in flow), VoucherProvider (no vendor concept), TaskProvider/BatchPlanner, CaptchaProvider (the SMS tab loads the vendor's Aliyun slider in the browser; the module solves nothing server-side), HintProvider, BundleImporter, ConversationBinder, Degrader, HealthProvider/PoolStatsReporter |
opencode |
AccountManager accounts.go:119; CredentialImporter credential.go:227, :305; LoginProvider login.go:86; RealmLoginProvider login.go:91 (realms free anonymous + oauth device code); ModelRefresher opencode.go:202; ModelLimitsProvider models.go:417; PoolStatsReporter pool.go:634 |
BalanceProvider (Zen exposes no balance, credit or quota endpoint at all: /zen/v1/key, /zen/v1/credits and /zen/v1/me are 404 with an HTML body, and the binary contains no such path — billing is console-only, so a fabricated 0 would be worse than saying so), Reviver/CaptchaProvider (OAuth tokens are refreshed lazily before a call; there is no separate health record to revive and no captcha), CheckinProvider/TaskProvider/BatchPlanner (no such API), PackageProvider/VoucherProvider/BundleImporter, ConversationBinder, HintProvider, Degrader |
openrouter |
AccountManager accounts.go:24; CredentialImporter credential.go:177, :265; LoginProvider login.go:273 (browser PKCE); BalanceProvider balance.go:29; ModelRefresher models.go:443; ModelLimitsProvider models.go:522; PoolStatsReporter openrouter.go:291; HealthProvider openrouter.go:299; LiveReloader openrouter.go:326 |
Reviver/RealmLoginProvider/CaptchaProvider (a PKCE-issued key never expires on its own, and there is one realm and no captcha), CheckinProvider/TaskProvider/BatchPlanner (the vendor has no check-in and no task board), VoucherProvider/PackageProvider (no such concept), ConversationBinder (one upstream host makes stickiness meaningless), BundleImporter, HintProvider, Degrader |
kilocode |
AccountManager accounts.go:25; CredentialImporter credential.go:194, :288; ModelRefresher models.go:496; ModelLimitsProvider models.go:578; PoolStatsReporter kilocode.go:314; HealthProvider kilocode.go:326; ConversationBinder affinity.go:77, :90, :98; LiveReloader affinity.go:107 |
LoginProvider/DirectKeyProvider (a key is pasted from the dashboard; there is no redirect flow to reproduce), BalanceProvider (the gateway exposes no readable credit endpoint, and a fabricated 0 would be worse than saying so), Reviver (an API key never expires on its own; "refresh" is a probe), CheckinProvider/TaskProvider/BatchPlanner (no such API), PackageProvider/VoucherProvider/BundleImporter, HintProvider, Degrader, RealmLoginProvider/CaptchaProvider |
Two facts this table makes visible that no single module README states:
core.BatchPlanneris implemented byworkbuddy,zcode,minimaxcodeandloomy, and the scheduler no longer needs one to schedule a check-in.core.PlannedBatchesgives a module that only implementscore.CheckinProviderone syntheticcheckinbatch, andinternal/scheduler/scheduler.goplusinternal/panel/batches.goexecute that batch throughCheckinProvider.Checkin. Soworkbuddy(batches.goplans the reference's six batches,tasks.goruns the codes they name),zcode(onecheckinbatch over itsclaimaction) andminimaxcode(onecheckinbatch overdaily-signin) keep the task-code path, whileloomydeliberately publishes itsgrowthonboarding batch with a 10-secondTaskGap, so its first-run chores do not look like a scripted burst;trae,qwenwork,lobsterai,codeartsandraccoonappear in the task centre under the same sharedcheckintimetable, backed by the check-in their account rows already offer. A module with neither capability still answers[scheduler] idle: nothing scheduled, and the six chore aliases ininternal/panel/batches.goanswer 501 for it. The seventh alias,balance_all, is the exception and is deliberately not a batch: a balance is not a chore any module plans, sointernal/panel/batches.gointercepts it by name and hands it toScheduler.RunBalanceRefreshNow, which sweeps every module that can report a balance regardless of which client is in the path. Routing it through the batch table would have made the panel's 刷新余额 button a guaranteed 501. Inside workbuddy the split is deliberate:blackcatpublishes the real board codeblack_cat, while checkin/travel/activity/keepalive/growth publish synthetic chore codes thatRunTaskdispatches before it reads the board — a scheduled chore has no board row, and the board path would refuse it for that reason alone.- The static metadata table covers three modules, not fourteen.
trae,qwenwork,zcode,minimaxcode,cline,lobsterai,codearts,loomy,raccoon,openrouterandopencodehave no section ininternal/modelmeta/table.json, so their fallback is the vendor catalogue, thenmodels.dev, then the on-disk cache. That is deliberate — no authoritative source named their ids — but it means "the fallback table" is not uniform and must not be described as such.minimaxcodeis the extreme case: the upstream has no catalogue endpoint at all, so the only source is the desktop client's ownconfig.yaml.
Justified "no"s, in the modules' own words: qwenwork has no CredentialImporter
because its desktop client keeps the session inside the client's own store
(clients/qwenwork/accounts.go:26, pinned by clients/qwenwork/accounts_test.go:725);
tabbit has no Reviver because its State/Note are recomputed from the last
probe — the sidecar's /health, or the vendor catalogue for a web account — and
config.go locate() never consults health, so a revive button would provably do
nothing. (tabbit does implement CredentialImporter
(clients/tabbit/accounts.go:46): it lists the accounts it stores and the
browser cookie it can read out of the running Tabbit browser via the vendor's own
launcher, and it gained LoginProvider in clients/tabbit/login.go, a browser
hand-off rather than an HTTP flow.)
The interface contract says nothing about how a module reaches its vendor, and
clients/tabbit is the worked example of a module that reaches it two ways:
- web — the vendor's own web API (
web.tabbit.com), authenticated by thetokencookie of a signed-in Tabbit browser. The protocol is documented inclients/tabbit/README.md: create a room (POST /panel/session), open thejoinSSE stream before submitting (POST …/runs), take the deltas untilrun_completed, drop the room. The vendor retires a room after every run, which is why a multi-message request is flattened into onecontentstring. - sidecar — the GPL
tabbit2apibridge over HTTP, unchanged.
transport ("auto" by default) picks per request, and "auto" prefers web
whenever a web credential exists and has not been rejected. Three consequences are
worth copying into the next such module:
- A transport choice must not change what the caller sees. Both paths produce
the same
core.Eventsequence and the samecore.AccountRecordshape; only the sidecar path hasreasoning_content, tool calls and a usage frame, and the web path does not claim them. - A second transport needs its own credential kind, not a flag.
web-tokenaccounts store a cookie;sidecaraccounts store a base URL. Adding the cookie to the existing kind would have made "is this row usable" undecidable. - A transport that is a percentage, not a count, must not become a
BalanceProvider. The vendor reportsusage_percentage; the panel rendersBalance.Credits. Mapping one to the other would invent a unit, so the quota is folded into the Test result as a note instead (clients/tabbit/web.gousageNote).
Two more optional interfaces describe the pool, not the vendor. They exist so that the panel can say what the process is really doing, and so that a burst does not look like a vendor refusal:
core.PoolStatsReporter.PoolStats() PoolStats—in_flight,in_flight_full,sticky_sessions.in_flightcounts the live leases the request path takes,in_flight_fullhow many usable accounts are at their ceiling,sticky_sessionshow many conversation bindings the module is holding. A module that does not implement it is reported without the key rather than as zeros.core.HealthProvider.Health() Health—servable, plusready,cooling,disabled,total,realms, and anotenaming the reason whenservableis false.servableis deliberately stricter than "an account is healthy": a pool whose healthy accounts are all at their in-flight ceiling is not servable, which is what makes/healthzanswer 503 instead of sending the caller into the same wall.core.ErrBusyis the third piece: when the request path finds every usable account at its ceiling it returnscore.ErrBusyrather than waiting, and the gateway maps it to 429 +Retry-After: 1. Queueing would still deliver the burst the ceiling exists to prevent.error.codeis the gateway's, not the module's. A module never decides what goes in that field: it returns a*core.Failure(or a plain error) andinternal/gateway/server.go'serrorCodeFornames it symbolically (waf_ip_blocked,rate_limit_exceeded,quota_exhausted,account_auth_failed,session_dead,content_blocked,upstream_error, …), exactly as the reference does at itswriteOpenAIErrorcall sites. A vendor's numeric business code (4008,14018,11102) is never promoted toerror.code; it stays insidemessage, which is the only place the reference keeps it. That is why no module needs a code field oncore.Failure.pool.max_in_flight/pool.max_in_flight_globalarrive throughcore.LiveSettings(pointers:nilmeans "the file said nothing", so a partial reload does not clear a ceiling).0for the per-account value means "no ceiling"; the global value falls back to the per-account one when it is unset, so "unset" and "allow nothing" are not the same value.session_sticky.enabledtravels as a*booland is a switch, not a duration: a non-nilfalsestops binding conversations, while the TTL pair (ttl/gc_interval) keeps its own0= "not mentioned" convention and a module then keeps the window it was built with.core.PoolTuningcarries the pool policy knobs —breaker_threshold/breaker_cooldown/breaker_cooldown_max,degrade_threshold/degrade_cooldown/degrade_cooldown_max,soft_rate_max,idle_weight_per_hour/idle_weight_max,prefer_expiringandcost_explore_interval. Same pointer convention as the ceilings, with one deliberate exception:cost_explore_intervaltreats an explicit0as a value ("stop exploring"), not as "unmentioned", because there is no other way to switch exploration off. A module is free to implement any subset; the ones it ignores simply keep their built-in behaviour, andcore.ApplyLivereports how many modules it reached rather than failing when none does.- Penalties are an or-gate, not a sum. A module that implements the breaker and the degrade counter keeps three independent deadlines — the ordinary classification cooldown, the breaker's exponential backoff and the degrade penalty — and refuses an account while any of them is still in the future. The effective wait is therefore the latest of them, which is what makes "the longest wins, never added together" structural rather than arithmetic. The two counters are fed by disjoint failure sets: the breaker takes account-level evidence (token refresh failures that are not session-dead, and 5xx), the degrade counter takes failures that say nothing about the account (transport errors and unrecognised 4xx). A single failure never feeds both.
- Credits feed back into the pool.
core.BalanceProvider.AccountBalancereturns the remaining credits and, whensoon > 0, the part expiring inside that window plus the earliest expiry among live batches. A module that reads the balance is expected to write it back into its own picker (so an account parked for exhaustion is unfrozen once credits return, and soprefer_expiringhas something to sort on) rather than only reporting it to the panel. Unfreezing on balance is deliberately narrow: it clears an exhaustion park and nothing else, because soft-rate, WAF and session-dead parks each have their own recovery evidence and clearing them on a balance refresh would compress their real lifetime down to the refresh period. core.BundleImporteris the operator-supplied counterpart tocore.CredentialImporter:Importwalks files the module found on this machine,ImportBundleaccepts a document the caller uploads. Per-record failures go intoBundleImportReport.Errorsrather than into the returned error — one unusable row out of a hundred must not lose the other ninety-nine — and the returned error means only that the document could not be read at all.Capabilities.Bundlelights the panel's upload control.redis_modeis reported as"noop": the no-op store is a supported single-machine configuration, not a missing feature. There is nointernal/redisstorepackage in this tree — nothing here depends on one.
Only workbuddy applies the ceilings (clients/workbuddy/pool.go:435-582,
clients/workbuddy/health.go); every module implements LiveReloader and so
applies the prompt, scrubber and stickiness window — see the capability table in
section 5 for the per-module file.
- Create/delete
clients/<name>/. - Add/remove the blank import line in
clients/all/all.go. - Nothing else. No core edit, no other module edit.
If step 3 is ever required, the module boundary has been violated — fix the module, not the core.