feat(rkd): check the server API version before signing in #8
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/server-api-version"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The RKD server now reports its API contract version on
GET /api/health(rkd#1019, merged there as PR #1020):{"status":"ok","api_version":N}, with a bareOKfrom older servers counting as 0. This plugin needs App hosts, which no version-0 server has, so until now the sign-in died on a bareHTTP 404and a signed-in channel retried its socket forever without saying why. The plugin now checks first and says what is wrong.Closes #7
What it does
src/server-version.tsparses/api/healthexactly like the RKD app does and compares it againstMIN_SERVER_API_VERSION = 1.loginstops before asking for a code, naming the server, both versions and the fix. The channel doesn't start its socket, andstatusshows the error.checkClientVersiontreats the Claude Code version.statusgains aserver api: N (needs 1 or newer)line.The pre-login checks move into
loginPreflight()so they are testable. Plugin 0.4.0; README ("Tested with") and/rkd:configuremention the requirement.Before / after
Real CLI,
login prod. Prod still runs a pre-contract server:Against a stub reporting
api_version: 1, 0.4.0 goes straight on to the sign-in code (STUB-0001).Channel mode (
RKD_CHANNEL=1, fake token, throwaway state dir),statustool plus stderr, against a stub that answers a bareOK:Against a stub reporting 1, 0.4.0 shows
server api: 1 (needs 1 or newer)and starts the socket as before.Test plan
pnpm test: 124 passed (19 new inserver-version.test.ts: parser, check,loginPreflight)pnpm typecheck,pnpm check:dist(committed bundle is current),scripts/smoke-handshake.mjsOK→0 rule,<→<=, the negative-version guard, the non-2xx and unrecognised-body warnings, the unreachable short-circuit, the ok/problem split, and not passingfetchthroughNotes
The runtime gate in
server.tshas no unit test because the module is the entry script. It is covered by the channel-mode run above. When the server later bumpsAPI_VERSIONfor something this plugin uses, raiseMIN_SERVER_API_VERSIONin the same release.https://claude.ai/code/session_01GK26pQScDqE52RKrrCTVso
The RKD server now reports its API contract version on /api/health ({"status":"ok","api_version":N}; a server from before the contract answers a bare OK = 0). This plugin needs App hosts, which no version-0 server has, so against one the sign-in died on a bare `HTTP 404` from /api/app-hosts/device and a signed-in channel retried its socket forever without a reason. server-version.ts parses /api/health the same way the RKD app does and compares against MIN_SERVER_API_VERSION = 1. Below it: - `login` stops before asking for a code, naming the server, both versions and the fix; - the channel doesn't start its socket, and `status` shows the error. `status` also shows `server api: N (needs 1 or newer)`. An unreachable server, a non-2xx or an unrecognised body only warns, so a flaky network is never mistaken for an old server. The login checks move into loginPreflight() so they are testable; 19 new tests, every hand-applied mutation killed. Plugin 0.4.0; README and /rkd:configure mention the requirement. Claude-Session: https://claude.ai/code/session_01GK26pQScDqE52RKrrCTVso