feat(server): request updates through a systemd trigger (#15)

The service stays unprivileged: POST /api/settings/update only writes the
update-request file in the data directory, which a root-owned path unit
watches. Status comes from systemctl show and the root-owned update log;
the check fetches the tracked branch into FETCH_HEAD and lists new commits.
This commit is contained in:
Florian Schmidt
2026-11-16 15:31:00 +01:00
parent ebf8649ab6
commit 2fc5f99f59
5 changed files with 388 additions and 1 deletions
+27
View File
@@ -145,6 +145,33 @@ export interface SessionSettingsResponse { lifetimeSeconds: number }
export interface ClaudeStatusResponse { available: boolean; version: string | null; loginAppearsPresent: boolean }
export interface SystemInfoResponse { version: string; workspacePath: string; dataDirPath: string; nodeVersion: string }
// Self-update from the UI (#15). The service stays unprivileged: POST only touches a
// request file that a root-owned systemd path unit watches (deploy/install.sh).
// GET /api/settings/update
export type UpdateState = "idle" | "running" | "succeeded" | "failed" | "unknown";
export interface UpdateStatusResponse {
/** The trigger units are installed; otherwise updates need `shellbook-update` as root. */
available: boolean;
state: UpdateState;
/** Installed commit (short hash) when the app runs from a git checkout. */
current: string | null;
startedAt: string | null;
finishedAt: string | null;
/** End of the last update's output. */
log: string;
}
// POST /api/settings/update/check: fetches the tracked branch, changes nothing else.
export interface UpdateCheckResponse {
current: string | null;
latest: string | null;
/** The checkout is pinned to a ref (SHELLBOOK_REF) and is never pulled. */
pinned: boolean;
/** Commits the update would bring, newest first (at most 50). */
changes: { commit: string; subject: string }[];
}
// POST /api/settings/update: 202, or 409 when unavailable or already running.
export interface UpdateStartResponse { requestedAt: string }
// ---- notebook management (#9) ------------------------------------------------
// Paths are relative to notebooks/. Mutations return 409 on stale versions or occupied targets.
// POST /api/notebooks