Writing your own server
The interface is currently in Chinese; an English interface is planned.
The interface between the browser extension and a server is written down in a contract, Server Contract v1. Implement it and the extension can connect to a server you wrote yourself.
Only half of this page is written: what the contract covers is below. Links to the full contract, the machine-readable API description, the reference server and the conformance tests will come once the site has its own place to host them.
Mind the version: the contract only becomes usable with a later extension release. The current store version is 0.2.2, which doesn’t yet have the “my own server” option that uses this contract.
What the contract covers
| Part | Endpoint | Required? |
|---|---|---|
| Handshake | GET /contract: returns contract_version, the household ID household.id (must not change at the same address), the household name household.name, and a features object (may be empty {}) |
Required |
| Join | POST /auth/join: redeems an invite code |
Required |
| Bind | POST /auth/bind: registers a key for this browser |
Required |
| Refresh | POST /auth/refresh |
Required |
| Sign out | DELETE /installs/{install_id} |
Required |
| Library | GET /kb/me, POST /kb/items (save one item) |
Required |
| Library (unified write) | POST /kb/capture, GET /kb/captures/{capture_id} |
Optional |
| Home AI | POST /ai/chat/completions (streaming), thinking levels off / deep |
Optional |
Every path sits under /app/v1 and is served over https: for a server at kb.example.com, the handshake address is kb.example.com/app/v1/contract.
How the extension decides compatibility
The extension only looks at contract_version (like "1.0") in the GET /app/v1/contract response. A new major version means incompatible; minor versions only add, never change. The first extension version that speaks this contract accepts 1.0 through 1.999. If it can’t accept the version, it says so in one line, stores nothing and never sends the invite code.
The hard requirements
- HTTPS only, and these endpoints must not answer with a 3xx redirect.
- Business endpoints accept only the
Authorization: Bearer <access token>header; no cookies, and don’t set any. /contractrequires, reads and returns no credentials.- Invite codes work once; bind must verify a P-256 signature; refresh tokens rotate on every use, and replaying an old one gets a 401 (you may allow a grace for the one just replaced whose reply never arrived: at most 60 seconds, and it ends as soon as the new pair is used).
- The library is idempotent on
client_key; page content sent to the Home AI is untrusted input; you should rate-limit. - The human-readable error message may be shown to the user as is, so never put tokens, invite codes, internal addresses or other users’ details in it.
Reference server and conformance tests
- Reference server: built only on Node’s built-in modules (Node 20 or later), keeps everything in memory and connects to no model. One command starts it and prints its address and freshly generated one-time invite codes (two by default, one per family member). It shows what “correct” looks like for each endpoint; it isn’t meant for real use.
- Conformance tests: run them against any server built to the contract; each check prints pass / fail / skipped, and the last line gives the total. They use up the invite code you provide and leave 2–3 items titled starting with 「一致性测试」 (“conformance test”) in that member’s library.
Last verified on 2026-11-23