feat: add managed database capture and operator restore

PostgreSQL and MySQL backups run through paired outposts, with operator sign-in, off-site copies, and legacy import. Retention stays on each orbit, so the unused retention console is removed.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-10 23:26:49 +07:00
parent 30a1a9b8f0
commit 6320b6f244
96 changed files with 11061 additions and 725 deletions

View File

@@ -12,12 +12,18 @@ export function formatWhen(iso: string): string {
});
}
export function schedulePhrase(cron?: string | null, dryRun?: boolean): string {
if (dryRun) return "Rehearse — no vault write";
if (!cron) return "On your command";
if (cron.includes("0 2")) return "Every night at 2am";
if (cron.includes("0 */6")) return "Every six hours";
return cron;
export function schedulePhrase(orbit: import("../api").Orbit): string {
if (orbit.access === "outpost") {
const schedule = orbit.capture_schedule;
if (!schedule) return orbit.application_id ? "On your command" : "Started by the Outpost";
const time = [schedule.hour, schedule.minute].map((part) => String(part).padStart(2, "0")).join(":");
return `Daily at ${time} ${schedule.timezone}`;
}
const cron = orbit.schedule?.trim().replace(/\s+/g, " ");
if (!cron) return orbit.dry_run ? "Rehearse on command" : "On your command";
if (cron === "0 2 * * *" || cron === "0 0 2 * * *") return "Daily at 02:00 UTC";
if (cron === "0 */6 * * *" || cron === "0 0 */6 * * *") return "Every six hours (UTC)";
return `${cron} (UTC)`;
}
export type VaultStatus = "green" | "amber" | "grey" | "red";
@@ -25,6 +31,7 @@ export type VaultStatus = "green" | "amber" | "grey" | "red";
export function orbitStatus(status: string): { label: string; tone: VaultStatus; busy?: boolean } {
switch (status) {
case "failed": return { label: "Failed", tone: "red" };
case "queued": return { label: "Queued", tone: "amber", busy: true };
case "running": return { label: "Running", tone: "amber", busy: true };
case "rehearsing": return { label: "Rehearsing", tone: "amber", busy: true };
case "rehearsed": return { label: "Rehearsed", tone: "amber" };

View File

@@ -13,12 +13,14 @@ export function placeLabels(
width: number,
height: number,
obstacles: Rect[],
selectedId?: string,
): Label[] {
const occupied = [...obstacles];
const placed: Label[] = [];
for (const label of candidates) {
const { x, y, width: w } = label;
const offsets = [12, 28, 44].flatMap((gap) => [
const gaps = label.id === selectedId ? [12, 28, 44, 64, 88, 112, 144, 180] : [12, 28, 44];
const offsets = gaps.flatMap((gap) => [
[gap, -LABEL_HEIGHT / 2], [-w - gap, -LABEL_HEIGHT / 2],
[-w / 2, -LABEL_HEIGHT - gap], [-w / 2, gap],
[gap, -LABEL_HEIGHT - gap / 2], [-w - gap, gap / 2],

View File

@@ -103,3 +103,16 @@ export function spiralPoint(source: Vec2, progress: number): Vec2 {
const radius = Math.hypot(source.x, source.y) * (1 - u ** 1.4);
return { x: Math.cos(angle) * radius, y: Math.sin(angle) * radius };
}
export const CAPTURE_HIGHLIGHT_START = 0.94;
export function capturePhases(progress: number) {
const stage = (start: number, end: number) => Math.min(1, Math.max(0, (progress - start) / (end - start)));
return {
flare: stage(0, 0.06) * (1 - stage(0.08, 0.24)),
flight: stage(0.09, 0.79),
absorption: stage(0.76, 0.84) * (1 - stage(0.85, CAPTURE_HIGHLIGHT_START)),
highlight: stage(CAPTURE_HIGHLIGHT_START, 0.97) * (1 - stage(0.97, 0.998)),
failure: stage(0, 0.15) * (1 - stage(0.17, 0.9)),
};
}

View File

@@ -5,12 +5,24 @@ export const uiSpring = {
stiffness: 320,
damping: 36,
mass: 1,
restDelta: 0.01,
restSpeed: 0.05,
} as const satisfies Transition;
export const ambientPulse = {
export const gentleSpring = {
...uiSpring,
stiffness: 180,
damping: 28,
} as const satisfies Transition;
export const ambientSpring = {
...uiSpring,
stiffness: 40,
damping: 13,
} as const satisfies Transition;
export const ambientPulse = {
...ambientSpring,
repeat: Infinity,
repeatType: "mirror",
} as const satisfies Transition;

View File

@@ -0,0 +1,65 @@
import type { Orbit, Snapshot } from "../api";
import type { HUDMode } from "../components/hud/HUDRail";
import { formatWhen } from "./format.ts";
type Navigation = { id: Exclude<HUDMode, "snapshot">; label: string; icon: string };
export type SearchResult =
| (Navigation & { kind: "navigation"; detail?: undefined })
| { kind: "orbit" | "snapshot"; id: string; label: string; detail: string };
type Candidate = { result: SearchResult; fields: string[]; timestamp?: number };
function matchRank(fields: string[], term: string) {
return Math.min(...fields.map(value => {
const field = value.toLowerCase();
if (field === term) return 0;
if (field.startsWith(term)) return 1;
if (field.includes(term)) return 2;
return Infinity;
}));
}
export function createVaultSearch(
navigation: readonly Navigation[],
orbits: readonly Pick<Orbit, "id" | "name" | "provider">[] = [],
snapshots: readonly Snapshot[] = [],
) {
const destinations = navigation.map(item => ({ ...item, kind: "navigation" as const }));
const categories: [string, Candidate[]][] = [
["Navigation", destinations.map(result => ({ result, fields: [result.label] }))],
["Orbits", orbits.map(({ id, name, provider }) => ({
result: { kind: "orbit", id, label: name, detail: `${provider} · ${id}` },
fields: [name, id, provider],
}))],
["Snapshots", snapshots.map(({ id, orbit_id, orbit_name, taken_at }) => {
const date = formatWhen(taken_at);
return {
result: { kind: "snapshot", id, label: orbit_name, detail: `${date} · ${id}` },
fields: [orbit_name, id, orbit_id ?? "", date],
timestamp: Date.parse(taken_at) || 0,
};
})],
];
return (query: string): { label: string; results: SearchResult[] }[] => {
const term = query.trim().toLowerCase();
if (!term) return [{ label: "Navigation", results: destinations.slice(0, 8) }];
const groups = categories.map(([label, candidates]) => ({
label,
results: candidates
.map(candidate => ({ ...candidate, rank: matchRank(candidate.fields, term) }))
.filter(({ rank }) => Number.isFinite(rank))
.sort((a, b) => a.rank - b.rank || (b.timestamp ?? 0) - (a.timestamp ?? 0) ||
a.result.id.localeCompare(b.result.id))
.map(({ result }) => result),
})).filter(({ results }) => results.length);
let remaining = 8;
return groups.map(({ label, results }, index) => {
// Leave at least one slot for each later category with matches.
const visible = results.slice(0, remaining - (groups.length - index - 1));
remaining -= visible.length;
return { label, results: visible };
});
};
}