Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f

### Added

- **Rename the cluster.** Settings → Hosts shows the cluster's name with a **Rename cluster** button; the sidebar group follows. The cluster is still created as "Cluster" when the first host joins, so rename it afterwards. `PATCH /api/hosts { poolId, label }` renames a pool without replacing the pool registry.
- **Cluster members use this machine's omp configuration.**
**Before upgrading:** every cluster member needs an ompweb host daemon at link protocol 10. Until a member's daemon is updated, sessions cannot start there (the start is refused and names the update), cluster placement skips it, a host below protocol 10 cannot join, and Settings → Hosts says it needs an update. Once its daemon is updated, every host already in the first pool receives this machine's configuration, secrets included (API keys, MCP environments and headers, tokens), automatically and without a confirmation having been shown, and its own omp configuration is replaced until it leaves the cluster; it is kept in `<agent dir>/omp-web/own-config/` on the member and put back on leaving. To avoid that for a host, remove it from the first pool (`PUT /api/hosts`, or editing `~/.omp/agent/omp-web/pools.json`) before updating its daemon. Update the web server first, then the members.
A cluster session now runs with this machine's settings (`config.yml`, without the machine-specific keys), `models.yml`, MCP servers, skills, task agents, rules and context files, commands, prompts, hooks, extensions, custom tools, `secrets.yml`, `.env`, the agent environment variables of Settings → System, and the installed plugins, whichever member it runs on. A change made here, in Settings or on disk, reaches the members within about a minute and before every session start on a member. Every cluster session start carries this machine's version: a start that must run on one member is refused with the reason when its files cannot be applied, and new sessions are placed only on members with the current configuration and plugins; a session recovered after a daemon restart, or started by another ompweb server, runs on whatever is on the member's disk, and running sessions are not restarted. A mirrored directory becomes equal to this machine's. The member's backup holds only what the host had when it joined: a file it adds or edits afterwards is deleted at the next apply, not backed up. Settings that describe the machine itself stay the member's own as they were when the host joined (see the README). A host holds one ompweb server's configuration: a host already in another server's cluster cannot join (409 `host_in_other_cluster`), and a member that also runs sessions for another server runs them on this one's configuration. The configuration contains secrets, which are written to every member's disk, readable by the daemon's user only; the hooks, extensions, tools and plugins in it run on every member, and this machine can already start omp with full tool access there. Each file is limited to 5 MiB and the configuration to 50 MiB; a configuration over a limit, or one that cannot be read, is not mirrored at all, a cluster session start on a member is refused (409 `cluster_config_invalid`), placement skips every member, and Settings names the file. Each download has a 30 s limit including the body (a 5 MiB file needs roughly 1.4 Mbit/s). An apply is refused on a member where `~/.agents` is a symbolic link, and the mirrored directories and the backup must be on one filesystem. The reverse proxy must pass `/api/hosts/cluster-config/manifest` and `/api/hosts/cluster-config/file/<hash>` without its own authentication, at exactly these paths (unlike the broker's prefix).
Expand Down
24 changes: 24 additions & 0 deletions app/api/hosts/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export async function POST(req: Request) {

export async function PATCH(req: Request) {
const body = await readBody(req);
if (body && body.poolId !== undefined) return renamePool(body);
if (!body || typeof body.id !== "string" || !body.id) return fail("id is required", 400);
const isLocal = body.id === "local";
if (isLocal && body.allowAgentStart !== undefined) return fail("This machine's agent-start setting cannot be changed", 400);
Expand All @@ -162,6 +163,29 @@ export async function PATCH(req: Request) {
}
}

/** `{ poolId, label }`: renames one pool (the cluster) without replacing the registry the way PUT does. */
function renamePool(body: Record<string, unknown>) {
if (!hasOnlyKeys(body, ["poolId", "label"]) || typeof body.poolId !== "string") return fail("poolId and label are required", 400);
const label = parseLabel(body.label);
if (!label) return fail(`label must be a non-empty string of at most ${MAX_LABEL_LENGTH} characters`, 400);
let pools: HostPool[];
try {
pools = loadPools();
} catch {
return poolStorageFailure();
}
const pool = pools.find((candidate) => candidate.id === body.poolId);
if (!pool) return fail("Unknown pool", 404);
pool.label = label;
try {
savePools(pools);
} catch {
return poolStorageFailure();
}
notifyHostsChange();
return Response.json({ pools }, { headers: noStore });
}

export async function DELETE(req: Request) {
const id = new URL(req.url).searchParams.get("id");
if (!id) return fail("id is required", 400);
Expand Down
22 changes: 17 additions & 5 deletions components/HostsConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { useHostRows } from "@/hooks/useHostRows";
import { HOST_STATUS_COLOR, hostName, hostStatusText, isLocalRow, localInstallCommand } from "./host-status";
import { HostUpdates } from "./HostUpdates";

type Dialogs = { kind: "add" } | { kind: "rename"; host: HostRow } | null;
type Dialogs = { kind: "add" } | { kind: "rename"; host: HostRow } | { kind: "renameCluster"; pool: HostPool } | null;

const inputStyle = { width: "100%", padding: "7px 9px", border: "1px solid var(--border)", borderRadius: "var(--radius-control)", background: "var(--bg)", color: "var(--text)", font: "13px var(--font-mono)" } as const;
const buttonStyle = { padding: "6px 14px", background: "none", border: "1px solid var(--border)", borderRadius: "var(--radius-control)", color: "var(--text-muted)", cursor: "pointer", fontSize: 13 } as const;
Expand Down Expand Up @@ -51,12 +51,12 @@ export function CopyField({ label, value }: { label: string; value: string }) {
);
}

/** Name form shared by "Add host" and "Rename"; adding ends in the one-time token view. */
/** Name form shared by "Add host" and "Rename" (a host or the cluster); adding ends in the one-time token view. */
function HostDialog({ dialog, onClose }: { dialog: NonNullable<Dialogs>; onClose: () => void }) {
const { t } = useI18n();
const adding = dialog.kind === "add";
const local = dialog.kind === "rename" && dialog.host.id === "local";
const [label, setLabel] = useState(dialog.kind === "rename" ? dialog.host.label : "");
const [label, setLabel] = useState(dialog.kind === "rename" ? dialog.host.label : dialog.kind === "renameCluster" ? dialog.pool.label : "");
const [busy, setBusy] = useState(false);
const hintId = useId();
const [created, setCreated] = useState<{ token: string; command: string } | null>(null);
Expand All @@ -68,6 +68,9 @@ function HostDialog({ dialog, onClose }: { dialog: NonNullable<Dialogs>; onClose
if (dialog.kind === "add") {
const data = await call("POST", "/api/hosts", { label });
setCreated({ token: String(data.token), command: String(data.command) });
} else if (dialog.kind === "renameCluster") {
await call("PATCH", "/api/hosts", { poolId: dialog.pool.id, label });
onClose();
} else {
await call("PATCH", "/api/hosts", { id: dialog.host.id, label });
onClose();
Expand All @@ -79,7 +82,7 @@ function HostDialog({ dialog, onClose }: { dialog: NonNullable<Dialogs>; onClose
}
};

const title = created || adding ? t("hostsConfig.addTitle") : t("hostsConfig.renameTitle");
const title = created || adding ? t("hostsConfig.addTitle") : dialog.kind === "renameCluster" ? t("hostsConfig.renameClusterTitle") : t("hostsConfig.renameTitle");
return (
// The token is shown once: only Done may close it, never Escape or an outside press.
<Dialog open onOpenChange={(open) => { if (!open && !created) onClose(); }}>
Expand Down Expand Up @@ -305,7 +308,8 @@ export function HostsConfig() {
const localBlock = poolsLoaded && localJoins && local ? joinBlock(local) : null;
const localReason = !local || localBlock === null ? null
: localBlock === "omp-old" ? t("hostsConfig.joinOmpOld", { name: hostName(t, local) }) : t("hostsConfig.joinLocalRestart");
const linkedMembers = clusterOf(pools)?.members.some((member) => member.hostId !== LOCAL_HOST_ID) ?? false;
const cluster = clusterOf(pools);
const linkedMembers = cluster?.members.some((member) => member.hostId !== LOCAL_HOST_ID) ?? false;

const share = async () => {
if (!sharing) return;
Expand Down Expand Up @@ -364,6 +368,14 @@ export function HostsConfig() {
<Plus size={14} aria-hidden="true" />{t("hostsConfig.add")}
</button>
</div>
{cluster && (
<div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", gap: 12 }}>
<span style={{ fontSize: 13, color: "var(--text)", fontWeight: 500, overflowWrap: "anywhere" }}>{t("hostsConfig.clusterName", { name: cluster.label })}</span>
<button type="button" className="ui-focus-ring" style={{ ...buttonStyle, display: "inline-flex", alignItems: "center", gap: 5, flexShrink: 0 }} onClick={() => setDialog({ kind: "renameCluster", pool: cluster })}>
<Pencil size={13} aria-hidden="true" />{t("hostsConfig.renameCluster")}
</button>
</div>
)}
{loadFailed && <div role="alert" style={{ fontSize: 12, color: "var(--status-error)" }}>{t("hostsConfig.loadFailed")}</div>}
{/* Once for every member: none of them can get this machine's configuration (spec K1). */}
{masterConfigError && linkedMembers && <div role="alert" style={{ fontSize: 12, color: "var(--status-error)", overflowWrap: "anywhere" }}>{t("hostsConfig.masterConfigFailed", { reason: masterConfigError.message })}</div>}
Expand Down
2 changes: 1 addition & 1 deletion graphify-out/graph.json

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions lib/hosts/hosts-route.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -483,3 +483,14 @@ test("caller telemetry cannot make offline or v6 members eligible; real v8 capac
assert.equal((await send("PUT", { pools: [unprovisioned] })).status, 200);
assert.equal(await choose(), null, "administrative provisioning is distinct from live readiness");
});

test("PATCH { poolId, label } renames only that pool and keeps the rest of its configuration", async (t) => {
const pool = seedPools(t, ["local"]);
const response = await send("PATCH", { poolId: pool.id, label: " Proxmox " });
assert.equal(response.status, 200);
assert.deepEqual((await get()).pools, [{ ...pool, label: "Proxmox" }]);
assert.equal((await send("PATCH", { poolId: pool.id, label: " " })).status, 400);
assert.equal((await send("PATCH", { poolId: "missing", label: "x" })).status, 404);
assert.equal((await send("PATCH", { poolId: pool.id, label: "x", enabled: false })).status, 400);
assert.equal((await get()).pools[0].label, "Proxmox");
});
3 changes: 3 additions & 0 deletions lib/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,9 @@
"hostsConfig.masterConfigFailed": "Members cannot get this machine's configuration: {reason}",
"hostsConfig.poolsUnavailable": "The cluster configuration could not be loaded",
"hostsConfig.shareForced": "On while the host is in the cluster",
"hostsConfig.clusterName": "Cluster: {name}",
"hostsConfig.renameCluster": "Rename cluster",
"hostsConfig.renameClusterTitle": "Rename cluster",
"hostsConfig.rename": "Rename",
"hostsConfig.renameTitle": "Rename host",
"hostsConfig.renameAria": "Rename {name}",
Expand Down
3 changes: 3 additions & 0 deletions lib/i18n/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,9 @@
"hostsConfig.masterConfigFailed": "メンバーはこのマシンの設定を取得できません: {reason}",
"hostsConfig.poolsUnavailable": "クラスター設定を読み込めませんでした",
"hostsConfig.shareForced": "クラスター参加中は常にオン",
"hostsConfig.clusterName": "クラスター: {name}",
"hostsConfig.renameCluster": "クラスター名を変更",
"hostsConfig.renameClusterTitle": "クラスター名を変更",
"hostsConfig.rename": "名前を変更",
"hostsConfig.renameTitle": "ホスト名を変更",
"hostsConfig.renameAria": "{name} の名前を変更",
Expand Down
3 changes: 3 additions & 0 deletions lib/i18n/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,9 @@
"hostsConfig.masterConfigFailed": "成员无法获取本机的配置:{reason}",
"hostsConfig.poolsUnavailable": "无法加载集群配置",
"hostsConfig.shareForced": "主机在集群中时始终开启",
"hostsConfig.clusterName": "集群:{name}",
"hostsConfig.renameCluster": "重命名集群",
"hostsConfig.renameClusterTitle": "重命名集群",
"hostsConfig.rename": "重命名",
"hostsConfig.renameTitle": "重命名主机",
"hostsConfig.renameAria": "重命名 {name}",
Expand Down
3 changes: 3 additions & 0 deletions lib/i18n/locales/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,9 @@
"hostsConfig.masterConfigFailed": "成員無法取得本機的組態:{reason}",
"hostsConfig.poolsUnavailable": "無法載入叢集設定",
"hostsConfig.shareForced": "主機在叢集中時一律開啟",
"hostsConfig.clusterName": "叢集:{name}",
"hostsConfig.renameCluster": "重新命名叢集",
"hostsConfig.renameClusterTitle": "重新命名叢集",
"hostsConfig.rename": "重新命名",
"hostsConfig.renameTitle": "重新命名主機",
"hostsConfig.renameAria": "重新命名 {name}",
Expand Down
Loading