The contract moves from f5b3dbb to the server's dev at a25db24971a0: version.json says
{"app_api": 2}, and the server now writes its own show cards (tool_show.json: one from the tree,
one from a device) and the files routes (files_listing.json, file_content.json,
file_content_withheld.json). Tokens from the same commit change only in the header; the strings
regenerate unchanged.
- APP_API is 2, and it is now the floor as well as the ceiling: a protocol-3 server that still
says app API 1 is a 2.0 build from before the show route and the files, and is refused as too
old, as 1.x is.
- The files routes are modelled (FileEntry, FileListing, FileContent, Withheld) and ApiClient
reads them: files(path), fileContent(path), and webFile(path) for the web UI's /files/view.
- shownText is documented against the server's real route, GET /api/v2/chats/{chat}/show with
?node=&version= or ?shown=, plain text up to 1 MB, 413 / 415 / 404; ClientTest pins the paths.
- The hand-written show cards leave ShowAndServerTest; ContractTest reads the server's.
Nothing in the app reads /api/v2/devices for its own token (devices() has no caller), so apps no
longer being listed there changes nothing here.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
1.4 KiB
Kotlin
32 lines
1.4 KiB
Kotlin
package eu.llembas.android.api
|
|
|
|
/**
|
|
* The app API this app reads: 2, the server's 2.0 (no canvas, no `knowledge_bases`, the `show`
|
|
* card and its route, and the person's files). A server with a newer one is told about, not
|
|
* guessed at; one with an older one is refused, because 1 has neither the show route nor the
|
|
* files this app opens -- a 2.0 `dev` server from before the files routes still said 1.
|
|
*/
|
|
const val APP_API = 2
|
|
|
|
/**
|
|
* The device-link protocol of LLeMbas 2.0. This app is built for 2.0 -- the file tree, the
|
|
* access levels, the `show` card -- and a 1.x server (protocol 1 or 2) is refused with a
|
|
* sentence rather than half-working. The protocol, not the version string, is the test: a
|
|
* server's `dev` branch says 1.7.x until its first beta, and the protocol is what 2.0 raised on
|
|
* purpose so that old clients can tell.
|
|
*/
|
|
const val MIN_PROTOCOL = 3
|
|
|
|
/** Whether this app can work with a server, from its discovery document. */
|
|
enum class ServerFit { FITS, NOT_LEMBAS, TOO_OLD, TOO_NEW }
|
|
|
|
fun fit(found: Discovery): ServerFit {
|
|
val protocol = maxOf(found.protocol, found.protocols.maxOrNull() ?: 0)
|
|
return when {
|
|
found.service != "lembas" -> ServerFit.NOT_LEMBAS
|
|
protocol < MIN_PROTOCOL || found.appApi < APP_API || "app" !in found.scopes -> ServerFit.TOO_OLD
|
|
found.appApi > APP_API -> ServerFit.TOO_NEW
|
|
else -> ServerFit.FITS
|
|
}
|
|
}
|