Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
feat: add minimum CLI version gate for web app (#42)
Gener275faf28a0ff
diff --git a/src/web/src/app/api/config/min-version/route.ts b/src/web/src/app/api/config/min-version/route.tsnew file mode 100644index 000000000..f1c1fef0b--- /dev/null+++ b/src/web/src/app/api/config/min-version/route.ts@@ -0,0 +1,19 @@+import { getCloudflareContext } from "@opennextjs/cloudflare"+import { semverGte } from "@alook/shared";+import { withAuth } from "@/lib/middleware/auth";+import { writeJSON } from "@/lib/middleware/helpers";+import { fetchLatestCliVersion } from "@/lib/npm";++export const GET = withAuth(async () => {+ const { env } = getCloudflareContext()+ const raw = (env as Env).MIN_CLI_VERSION;+ if (!raw) return writeJSON({ min_cli_version: null });++ const latest = await fetchLatestCliVersion();+ if (latest && !semverGte(latest, raw)) {+ // MIN_CLI_VERSION is higher than what's published — ignore it+ return writeJSON({ min_cli_version: null });+ }++ return writeJSON({ min_cli_version: raw });+});diff --git a/src/web/src/app/api/runtimes/[runtimeId]/update/route.ts b/src/web/src/app/api/runtimes/[runtimeId]/update/route.tsindex 6ffb7b3a1..120d81301 100644--- a/src/web/src/app/api/runtimes/[runtimeId]/update/route.ts+++ b/src/web/src/app/api/runtimes/[runtimeId]/update/route.ts@@ -5,17 +5,7 @@ import { getDb } from "@/lib/db"import { withAuth } from "@/lib/middleware/auth";import { withWorkspaceMember } from "@/lib/middleware/workspace";import { writeJSON, writeError } from "@/lib/middleware/helpers";--async function fetchLatestCliVersion(): Promise<string | null> {- try {- const res = await fetch("https://registry.npmjs.org/@alook/cli/latest");- if (!res.ok) return null;- const data = (await res.json()) as { version?: string };- return data.version ?? null;- } catch {- return null;- }-}+import { fetchLatestCliVersion } from "@/lib/npm";export const POST = withAuth(async (req: NextRequest, ctx) => {const ws = await withWorkspaceMember(req, ctx);diff --git a/src/web/src/components/runtime-version-gate.tsx b/src/web/src/components/runtime-version-gate.tsxnew file mode 100644index 000000000..6ad738550--- /dev/null+++ b/src/web/src/components/runtime-version-gate.tsx@@ -0,0 +1,117 @@+"use client";++import { useEffect, useState } from "react";+import { useAgentContext } from "@/contexts/agent-context";+import { getMinCliVersion, triggerRuntimeUpdate } from "@/lib/api";+import { semverGte } from "@alook/shared";+import {+ Dialog,+ DialogContent,+ DialogHeader,+ DialogTitle,+ DialogDescription,+} from "@/components/ui/dialog";+import { Button } from "@/components/ui/button";+import { Badge } from "@/components/ui/badge";+import { AlertTriangle, RefreshCw } from "lucide-react";+import type { AgentRuntime } from "@alook/shared";++export function RuntimeVersionGate() {+ const { runtimes, workspaceId } = useAgentContext();+ const [minVersion, setMinVersion] = useState<string | null>(null);+ const [updating, setUpdating] = useState<Set<string>>(new Set());++ useEffect(() => {+ getMinCliVersion().then((res) => setMinVersion(res.min_cli_version)).catch(() => {});+ }, []);++ if (!minVersion) return null;++ const outdatedRuntimes = runtimes.filter((rt) => {+ if (rt.status !== "online") return false;+ const cliVersion = (rt.metadata as Record<string, unknown>)?.cli_version;+ if (typeof cliVersion !== "string" || !cliVersion) return true;+ return !semverGte(cliVersion, minVersion);+ });++ // Deduplicate by daemon_id — show one card per machine+ const outdatedMachines = new Map<string, AgentRuntime>();+ for (const rt of outdatedRuntimes) {+ const key = rt.daemon_id ?? rt.id;+ if (!outdatedMachines.has(key)) outdatedMachines.set(key, rt);+ }++ if (outdatedMachines.size === 0) return null;++ const handleUpdate = async (rt: AgentRuntime) => {+ setUpdating((prev) => new Set(prev).add(rt.id));+ try {+ await triggerRuntimeUpdate(rt.id, workspaceId);+ } catch {+ setUpdating((prev) => {+ const next = new Set(prev);+ next.delete(rt.id);+ return next;+ });+ }+ };++ return (+ <Dialog+ open+ modal+ disablePointerDismissal+ onOpenChange={() => {}}+ >+ <DialogContent showCloseButton={false}>+ <DialogHeader>+ <DialogTitle className="flex items-center gap-2">+ <AlertTriangle className="size-5 text-amber-500" />+ Runtime Update Required+ </DialogTitle>+ <DialogDescription>+ The following machine(s) are running an outdated CLI version (minimum required: v{minVersion}). Please update to continue.+ </DialogDescription>+ </DialogHeader>++ <div className="space-y-3 mt-2">+ {[...outdatedMachines.entries()].map(([daemonId, rt]) => {+ const cliVersion = (rt.metadata as Record<string, unknown>)?.cli_version as string | undefined;+ const isUpdating = updating.has(rt.id);++ return (+ <div+ key={daemonId}+ className="flex items-center justify-between rounded-lg border p-3"+ >+ <div className="flex items-center gap-3 min-w-0">+ <span className="size-2 shrink-0 rounded-full bg-emerald-500" />+ <div className="min-w-0">+ <div className="text-sm font-medium truncate">+ {rt.device_info || daemonId.slice(0, 12)}+ </div>+ <div className="text-xs text-muted-foreground flex items-center gap-2 mt-0.5">+ <span>v{cliVersion || "unknown"}</span>+ <Badge variant="outline" className="text-[10px] px-1.5 py-0 text-amber-500 border-amber-500/30">+ requires v{minVersion}+ </Badge>+ </div>+ </div>+ </div>+ <Button+ size="sm"+ variant="outline"+ disabled={isUpdating}+ onClick={() => handleUpdate(rt)}+ >+ <RefreshCw className={`size-3.5 ${isUpdating ? "animate-spin" : ""}`} />+ {isUpdating ? "Updating..." : "Update"}+ </Button>+ </div>+ );+ })}+ </div>+ </DialogContent>+ </Dialog>+ );+}diff --git a/src/web/src/components/workspace-shell.tsx b/src/web/src/components/workspace-shell.tsxindex 486e16c31..03bc7b401 100644--- a/src/web/src/components/workspace-shell.tsx+++ b/src/web/src/components/workspace-shell.tsx@@ -9,6 +9,7 @@ import {Sheet,SheetContent,} from "@/components/ui/sheet";+import { RuntimeVersionGate } from "@/components/runtime-version-gate";const SidebarTriggerContext = createContext<(() => void) | null>(null);@@ -36,6 +37,7 @@ export function WorkspaceShell({ children }: { children: ReactNode }) {<AppSidebar onNavigate={() => setSidebarOpen(false)} /></SheetContent></Sheet>+ <RuntimeVersionGate /></div></SidebarTriggerContext.Provider>);@@ -51,6 +53,7 @@ export function WorkspaceShell({ children }: { children: ReactNode }) {{children}</main></div>+ <RuntimeVersionGate /></div>);}diff --git a/src/web/src/env.d.ts b/src/web/src/env.d.tsindex 6eb7fc8c3..b14c26146 100644--- a/src/web/src/env.d.ts+++ b/src/web/src/env.d.ts@@ -19,6 +19,7 @@ declare namespace Cloudflare {AUTH_OTP_RATE_LIMIT_MAX?: stringAUTH_OTP_RATE_LIMIT_WINDOW_SEC?: stringRUNTIME_MODEL_OPTIONS?: string+ MIN_CLI_VERSION?: string}}diff --git a/src/web/src/lib/api.ts b/src/web/src/lib/api.tsindex f83777a34..b11fd59cd 100644--- a/src/web/src/lib/api.ts+++ b/src/web/src/lib/api.ts@@ -148,6 +148,9 @@ export const triggerRuntimeRescan = (runtimeId: string, workspaceId: string) =>{ method: "POST" });+export const getMinCliVersion = () =>+ apiFetch<{ min_cli_version: string | null }>("/api/config/min-version");+export const fetchLatestCliVersion = () =>apiFetch<{ version: string }>("/api/cli/latest-version");diff --git a/src/web/src/lib/npm.ts b/src/web/src/lib/npm.tsnew file mode 100644index 000000000..e4bfa1112--- /dev/null+++ b/src/web/src/lib/npm.ts@@ -0,0 +1,10 @@+export async function fetchLatestCliVersion(): Promise<string | null> {+ try {+ const res = await fetch("https://registry.npmjs.org/@alook/cli/latest");+ if (!res.ok) return null;+ const data = (await res.json()) as { version?: string };+ return data.version ?? null;+ } catch {+ return null;+ }+}diff --git a/src/web/wrangler.toml b/src/web/wrangler.tomlindex 896ebd077..6917726c8 100644--- a/src/web/wrangler.toml+++ b/src/web/wrangler.toml@@ -67,3 +67,4 @@ id = "a3d035bea7bc49d99377b82ec21ce4c1"[vars]RUNTIME_MODEL_OPTIONS = '{"claude":["claude-opus-4-6","claude-sonnet-4-6","claude-haiku-4-5"],"codex":["gpt-5.4","gpt-5.3-codex"]}'+MIN_CLI_VERSION = "0.0.26"