CI / check (push) Canceled after 0s
A native client for a LLeMbas instance on the server's /api/v2, and the phone's digital assistant. - Sign in by device code; the token sealed in the Android Keystore; several instances. - Chats and agent chats: the list, a chat with its reply streaming as JSON server-sent events (reconnecting, whole blocks), thinking, tool calls, steered messages, the plan, jobs, stop, edit, regenerate, continue, the model, effort and Plan mode, attachments and dictation. - Cards in a sheet, answered as the page's form says it; first answer wins. - Notifications through UnifiedPush, no Google services; an approval can be answered from its notification. - The digital assistant: a VoiceInteractionService with its session (a sheet over the current app, "Include screen" off by default), a recognition service through the instance's speech-to-text, the lock-screen path that asks to unlock before sending, a Quick Settings tile and an Ask shortcut. - Share to LLeMbas; Moria and Shire from the server's tokens; nine languages; a self-updater in the `full` flavour, none in `fdroid`. Generated and pinned from the server, each checked in CI: the theme (tokens.lock.json), the contract (contract/lock.json, server 2124ba9), the strings and the icons. Built and tested only on GitHub Actions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
65 lines
2.3 KiB
Python
Executable File
65 lines
2.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""The server's contract, pinned: `contract/*.json` from `tests/fixtures/api_v2/` at a ref.
|
|
|
|
scripts/fetch-contract.py <server-ref> copy the fixtures at that ref, write contract/lock.json
|
|
scripts/fetch-contract.py verify: contract/ matches contract/lock.json
|
|
|
|
The fixtures are written by the server's serialisers themselves (its
|
|
`tests/test_api_v2_contract.py`); `ContractTest` parses every one with this app's models. So a
|
|
shape the server changed is a failing test here, at the moment the pin moves -- not a blank
|
|
screen on a phone.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import hashlib
|
|
import json
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
SERVER = Path(os.environ.get("LEMBAS_SERVER", ROOT.parent / "LLeMbas"))
|
|
SOURCE = "tests/fixtures/api_v2"
|
|
OUT = ROOT / "contract"
|
|
LOCK = OUT / "lock.json"
|
|
|
|
|
|
def digest() -> str:
|
|
h = hashlib.sha256()
|
|
for path in sorted(OUT.glob("*.json")):
|
|
if path.name == LOCK.name:
|
|
continue
|
|
h.update(path.name.encode() + b"\0" + path.read_bytes())
|
|
return h.hexdigest()
|
|
|
|
|
|
def git(*args: str) -> str:
|
|
return subprocess.run(["git", "-C", str(SERVER), *args], capture_output=True, text=True, check=True).stdout
|
|
|
|
|
|
def main() -> None:
|
|
if len(sys.argv) == 1:
|
|
lock = json.loads(LOCK.read_text())
|
|
if digest() != lock["sha256"]:
|
|
sys.exit(f"fetch-contract: contract/ does not match {LOCK.name} (server {lock['ref']})")
|
|
print(f"fetch-contract: contract/ matches the server at {lock['ref']}")
|
|
return
|
|
ref = sys.argv[1]
|
|
commit = git("rev-parse", "--verify", f"{ref}^{{commit}}").strip()
|
|
names = [n for n in git("ls-tree", "--name-only", f"{commit}:{SOURCE}").split() if n.endswith(".json")]
|
|
if not names:
|
|
sys.exit(f"fetch-contract: no fixtures at {ref}:{SOURCE}")
|
|
OUT.mkdir(exist_ok=True)
|
|
for old in OUT.glob("*.json"):
|
|
old.unlink()
|
|
for name in names:
|
|
(OUT / name).write_text(git("show", f"{commit}:{SOURCE}/{name}"), encoding="utf-8")
|
|
LOCK.write_text(json.dumps({"ref": ref, "commit": commit, "sha256": digest()}, indent=2) + "\n")
|
|
print(f"fetch-contract: {len(names)} files from {ref} ({commit[:12]})")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|