Adds the Desktop-exclusive Preview models and the Xiaomi account-session
route to the existing xiaomi-mimo provider instead of a separate
xiaomi-desktop provider, so the dashboard shows one MiMo entry rather than
three overlapping ones.
Dual auth, same pattern as kimi — API key (sk-) covers the cloud API,
Desktop/OAuth adds the account session used by the Preview models:
- registry: category oauth, authModes [oauth, apikey], oauth block, the two
mimo-x-*-preview models, and the invite signupUrl
- executor: routes Preview models to the account-service route with a Cookie
session, everything else keeps the sourceFormat-matched transport
- oauth: custom ECDH encrypted-callback flow (X25519 -> SHA256 -> AES-256-GCM)
with a loopback callback proxy, plus one-click import of the local Desktop
auth.json
- usage: weekly quota from the account session
Fixes found while merging:
- the OAuth browser flow was dead: poll-status cleared the session before the
client could POST /exchange, so every exchange returned 400
- a Claude-format client was sent to /v1/chat/completions instead of the
declared /anthropic/v1/messages transport, because buildUrl ignored
runtimeTransport
- stopXiaomiMimoProxy leaked every pending session (each holding an X25519
private key) for the process lifetime
- the OAuth exchange did not persist the Desktop passToken, so the Preview
models could never work after a browser sign-in
Removes dead code: the local engine token minting (mimoEngine, never called
on the request path), the model-catalog and usage routes, engineToken/
engineUrl plumbing, and an unread top-level usage block.
Adds tests/unit/xiaomi-mimo-{executor,oauth-session,oauth-proxy}.test.js —
the provider previously had none.
9Router Embeddings Tests
Unit tests for the /v1/embeddings endpoint implementation.
Setup
Install test dependencies from the tests/ directory:
cd tests/ && npm install
Running Tests
From the tests/ directory:
npm test
Or run vitest directly with npx:
npx vitest run --reporter=verbose --config ./vitest.config.js
Test Files
| File | What it tests |
|---|---|
unit/embeddingsCore.test.js |
open-sse/handlers/embeddingsCore.js — core logic: body builder, URL router, headers, handler flow |
unit/embeddings.cloud.test.js |
cloud/src/handlers/embeddings.js — cloud worker handler: auth, validation, rate limits, CORS |
Coverage Summary (59 tests)
embeddingsCore.test.js (36 tests)
buildEmbeddingsBody: single string, array, encoding_format, default floatbuildEmbeddingsUrl: openai, openrouter, openai-compatible-*, unsupported providersbuildEmbeddingsHeaders: per-provider header sets, fallback to accessTokenhandleEmbeddingsCoreinput validation: missing, wrong type, null, emptyhandleEmbeddingsCoresuccess: response format, CORS, Content-Type, callbackshandleEmbeddingsCoreerrors: 400/429/500, network error, invalid JSONhandleEmbeddingsCoretoken refresh: 401 retry, graceful fallback
embeddings.cloud.test.js (23 tests)
- CORS OPTIONS: 200 response, empty body, correct headers
- Authentication: missing key, bad format, old-format key, wrong key value, valid key
- Body validation: invalid JSON, missing model, missing input, bad model
- Happy path: single string, array, correct delegation, CORS header, machineId override
- Rate limiting: all accounts rate-limited → 503 + Retry-After, no credentials → 400
- Error propagation: non-fallback errors passed through, 429 exhausts accounts
- machineId override: validates key, rejects wrong key