Open-source AI coworkers that each get a computer of their own: a browser, files and tools, with every action decided before it happens and recorded after. Bring any AG-UI agent.
import {
IconAlertTriangle,
IconDeviceDesktop,
IconRobot,
} from "@tabler/icons-react";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { createFileRoute, Link } from "@tanstack/react-router";
import { useState } from "react";
import {
PageEmpty,
PageRows,
PageSection,
PageShell,
} from "@/components/layout/page-shell";
import { StaggerItem } from "@/components/layout/stagger";
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
import {
Item,
ItemActions,
ItemContent,
ItemDescription,
ItemTitle,
} from "@/components/ui/item";
import { Separator } from "@/components/ui/separator";
import { useBotNames } from "@/lib/agents/bot-names";
import { agentListQueryOptions } from "@/lib/agents/queries";
import {
type HostAccessPendingOperation,
type HostFolderGrant,
hostAccessQueryOptions,
requestHostFolderGrantMutationOptions,
revokeHostFolderGrantMutationOptions,
stopHostAccessMutationOptions,
} from "@/lib/computers/host-access";
import { setComputerStateMutationOptions } from "@/lib/computers/mutations";
import {
type ComputerProfile,
computerFleetQueryOptions,
} from "@/lib/computers/queries";
export const Route = createFileRoute("/_authed/admin/computers")({
component: ComputersPage,
});
/** One row's identity: the computer, and on a shared computer the Bot's seat on it. */
function rowId(computer: ComputerProfile): string {
return `${computer.computer}|${computer.botId ?? ""}`;
}
function ComputersPage() {
/** The row currently running a stop/reset request. */
const [busy, setBusy] = useState<string | null>(null);
/** Reset deletes the browser profiles, so it requires confirmation. */
const [confirming, setConfirming] = useState<ComputerProfile | null>(null);
/** Updating restarts a running computer mid-task, so it is confirmed too. */
const [confirmingUpdate, setConfirmingUpdate] =
useState<ComputerProfile | null>(null);
const queryClient = useQueryClient();
const nameFor = useBotNames();
const fleet = useQuery(computerFleetQueryOptions());
const hostAccess = useQuery(hostAccessQueryOptions());
const agents = useQuery(agentListQueryOptions());
const setState = useMutation(setComputerStateMutationOptions(queryClient));
const requestGrant = useMutation(
requestHostFolderGrantMutationOptions(queryClient),
);
const revokeGrant = useMutation(
revokeHostFolderGrantMutationOptions(queryClient),
);
const stopHostAccess = useMutation(
stopHostAccessMutationOptions(queryClient),
);
const computers = fleet.data?.computers ?? null;
const isolation = fleet.data?.isolation ?? null;
/*
* A list that could not be read. A refused stop, reset or update is said beside the buttons
* instead, because the top of this page is a long scroll away from them.
*/
const problem = fleet.error
? "Couldn't load the computers. Reload the page."
: null;
const hostProblem = hostAccess.error
? hostAccess.error.message
: requestGrant.error
? requestGrant.error.message
: revokeGrant.error
? revokeGrant.error.message
: stopHostAccess.error
? stopHostAccess.error.message
: null;
const run = (
computer: ComputerProfile,
action: "stop" | "reset" | "update",
) => {
setBusy(rowId(computer));
setConfirming(null);
setConfirmingUpdate(null);
setState.mutate(
{
action,
computer: computer.computer,
...(computer.botId ? { botId: computer.botId } : {}),
},
{ onSettled: () => setBusy(null) },
);
};
/**
* Whose computer a row is, in the words the rest of Admin uses.
*
* A person's computer is named for the person. An isolated Bot's is named for the Bot. On a shared
* computer a row is one person's seat on one Bot, so it names both.
*/
const titleOf = (computer: ComputerProfile): string => {
const person =
computer.person?.name ?? computer.person?.email ?? computer.personId;
if (computer.kind === "person") {
return computer.botId
? `${person} · ${nameFor(computer.botId)}`
: `${person}'s computer`;
}
return nameFor(computer.botId ?? computer.computer);
};
/** What a row carries, said once before its state. */
const scopeOf = (computer: ComputerProfile): string => {
if (computer.kind === "person") {
return computer.botId
? "This person's profile and folder for this Bot"
: "Runs every Bot this person uses";
}
return isolation === "shared"
? "This Bot's profile from before each person had their own"
: "Isolated: a computer of its own, shared by everyone who uses it";
};
return (
<PageShell
description="Each person's computer, and each isolated Bot's. Every Bot keeps its own browser profile on it, which keeps that Bot signed in. Resetting a computer signs every Bot on it out of everything."
title="Computers"
>
{problem ? (
<p
className="mt-4 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm"
role="alert"
>
{problem}
</p>
) : null}
{isolation === "shared" ? (
<p className="mt-4 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm">
<span className="font-medium">
Every person's Bots run on one computer.
</span>{" "}
Each person keeps their own browser profile and folder for each Bot,
so logins aren't shared. A command one Bot runs can still read
another's files. Set <code>COMPUTER_SUPERVISOR_URL</code> to give each
person a computer of their own.
</p>
) : isolation === "per-person" ? (
<p className="mt-4 rounded-md border border-border bg-muted/40 px-3 py-2 text-muted-foreground text-sm">
Each person has their own computer, and every Bot they use runs on it,
public Bots made by other people included. Each Bot keeps its own
browser profile and folder there, but a command one Bot runs can reach
anything else on that person's computer. An isolated Bot has a
computer of its own.
</p>
) : null}
<HostFoldersSection
connected={hostAccess.data?.connected ?? false}
grants={hostAccess.data?.grants ?? []}
botIds={(agents.data ?? []).map((agent) => agent.id)}
loading={hostAccess.isPending || agents.isPending}
nameFor={nameFor}
onGrant={(botId) => requestGrant.mutate({ botId })}
onRevoke={(grantId) => revokeGrant.mutate({ grantId })}
onStop={() => stopHostAccess.mutate()}
pending={hostAccess.data?.pending ?? []}
problem={hostProblem}
requestingBotId={
requestGrant.isPending
? (requestGrant.variables?.botId ?? null)
: null
}
revokingGrantId={
revokeGrant.isPending
? (revokeGrant.variables?.grantId ?? null)
: null
}
stopping={stopHostAccess.isPending}
/>
<PageSection title="Computers in this deployment">
{setState.error ? (
<p
className="mb-3 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm"
role="alert"
>
{setState.error.message}
</p>
) : null}
{computers === null && problem ? (
<PageEmpty icon={IconAlertTriangle} title="Couldn't load the list" />
) : computers === null ? null : computers.length === 0 ? (
<PageEmpty icon={IconDeviceDesktop} title="No computers yet">
One shows up the first time a Bot opens a page.
</PageEmpty>
) : (
<PageRows>
{computers.map((computer, index) => (
<StaggerItem index={index} key={rowId(computer)}>
<Item size="sm">
<ItemContent>
<ItemTitle title={computer.computer}>
{titleOf(computer)}
</ItemTitle>
<ItemDescription>
{scopeOf(computer)}
{" · "}
{computer.running
? `Browser running since ${new Date(computer.startedAt ?? "").toLocaleTimeString()}`
: "No browser running. It starts when the Bot next needs it."}
{" · "}
{computer.egress === undefined
? "Egress not reported"
: computer.egress === null
? "Leaves directly"
: `Leaves through ${computer.egress}`}
{computer.updateAvailable ? " · Update available" : ""}
</ItemDescription>
</ItemContent>
<ItemActions>
{computer.updateAvailable ? (
<Button
disabled={busy === rowId(computer)}
onClick={() => setConfirmingUpdate(computer)}
size="sm"
variant="outline"
>
Update computer
</Button>
) : null}
<Button
disabled={busy === rowId(computer) || !computer.running}
onClick={() => void run(computer, "stop")}
size="sm"
variant="outline"
>
{busy === rowId(computer) ? "Working…" : "Stop browser"}
</Button>
<Button
disabled={busy === rowId(computer)}
onClick={() => setConfirming(computer)}
size="sm"
variant="outline"
>
Reset
</Button>
</ItemActions>
</Item>
{index !== computers.length - 1 && <Separator />}
</StaggerItem>
))}
</PageRows>
)}
</PageSection>
{/*
* A DIALOG RATHER THAN AN INLINE CONFIRM. Resetting signs a Bot out of everything it has ever
* logged into and cannot be undone, and the row it was confirmed on was one of several
* identical-looking rows. The dialog names whose computer it is, so the sentence somebody
* agrees to says which computer it destroys.
*/}
<Dialog
onOpenChange={(open) => {
if (!open) setConfirming(null);
}}
open={confirming !== null}
>
<DialogContent>
<DialogHeader>
<DialogTitle>
Reset {confirming ? titleOf(confirming) : ""}?
</DialogTitle>
<DialogDescription>
{confirming?.kind === "person" && !confirming.botId
? "Every Bot's profile on this person's computer is deleted. Each is signed out of every service and starts clean."
: "Its profile is deleted. The Bot is signed out of every service and starts clean."}{" "}
You can't undo this.
</DialogDescription>
</DialogHeader>
<DialogFooter>
<Button
onClick={() => setConfirming(null)}
size="sm"
variant="ghost"
>
Cancel
</Button>
<Button
disabled={confirming !== null && busy === rowId(confirming)}
onClick={() => {
if (confirming) void run(confirming, "reset");
}}
size="sm"
variant="destructive"
>
{confirming !== null && busy === rowId(confirming)
? "Resetting…"
: "Reset it"}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
<Dialog
onOpenChange={(open) => {
if (!open) setConfirmingUpdate(null);
}}
open={confirmingUpdate !== null}
>
<DialogContent>
<DialogHeader>
<DialogTitle>
Update {confirmingUpdate ? titleOf(confirmingUpdate) : ""}?
</DialogTitle>
<DialogDescription>
It moves to the computer image this deployment now runs. Its files
and sign-ins are kept. If it's running, it restarts and stops what
it's doing.
</DialogDescription>
</DialogHeader>
<DialogFooter>
<Button
onClick={() => setConfirmingUpdate(null)}
size="sm"
variant="ghost"
>
Cancel
</Button>
<Button
disabled={
confirmingUpdate !== null && busy === rowId(confirmingUpdate)
}
onClick={() => {
if (confirmingUpdate) void run(confirmingUpdate, "update");
}}
size="sm"
>
{confirmingUpdate !== null && busy === rowId(confirmingUpdate)
? "Updating…"
: "Update it"}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
<p className="mt-4 text-muted-foreground text-sm">
<strong>Stop</strong> closes the computer's browsers and keeps their
logins. It starts again the next time a Bot needs it.{" "}
<strong>Reset</strong> deletes the profiles and signs every Bot on it
out of everything. <strong>Update computer</strong> shows when a
computer runs an older image. It moves the computer to the new one and
keeps its files and sign-ins. All three show in{" "}
<Link className="underline" to="/admin/audit">
Audit
</Link>
.
</p>
</PageShell>
);
}
type HostFoldersSectionProps = {
botIds: string[];
connected: boolean;
grants: HostFolderGrant[];
loading: boolean;
nameFor: (botId: string) => string;
onGrant: (botId: string) => void;
onRevoke: (grantId: string) => void;
onStop: () => void;
pending: HostAccessPendingOperation[];
problem: string | null;
requestingBotId: string | null;
revokingGrantId: string | null;
stopping: boolean;
};
function HostFoldersSection({
botIds: knownBotIds,
connected,
grants,
loading,
nameFor,
onGrant,
onRevoke,
onStop,
pending,
problem,
requestingBotId,
revokingGrantId,
stopping,
}: HostFoldersSectionProps) {
const botIds = Array.from(
new Set([
...knownBotIds,
...grants.map((grant) => grant.botId),
...pending.map((one) => one.botId),
]),
).sort((left, right) => nameFor(left).localeCompare(nameFor(right)));
return (
<PageSection
description="Choose folders a Bot can read on this computer. The desktop app asks before each edit or command. Access ends when you stop OpenBot."
title="Folders on this computer"
>
{problem ? (
<p
className="mb-3 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm"
role="alert"
>
{problem}
</p>
) : null}
{!connected && !loading ? (
<p className="mb-3 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm">
The desktop app is offline. Open it to approve folders or run
commands.
</p>
) : null}
{loading ? null : botIds.length === 0 ? (
<PageEmpty icon={IconRobot} title="No Bots yet">
Create one, then choose its folders.
</PageEmpty>
) : (
<PageRows>
{botIds.map((botId, index) => (
<StaggerItem index={index} key={botId}>
<Item size="sm">
<ItemContent>
<ItemTitle title={botId}>{nameFor(botId)}</ItemTitle>
<ItemDescription>
{summaryFor(botId, grants, pending)}
</ItemDescription>
<FolderGrantList
botId={botId}
grants={grants}
onRevoke={onRevoke}
pending={pending}
revokingGrantId={revokingGrantId}
/>
</ItemContent>
<ItemActions>
<Button
disabled={!connected || requestingBotId === botId}
onClick={() => onGrant(botId)}
size="sm"
variant="outline"
>
{requestingBotId === botId ? "Waiting…" : "Choose folder"}
</Button>
</ItemActions>
</Item>
{index !== botIds.length - 1 && <Separator />}
</StaggerItem>
))}
</PageRows>
)}
<div className="mt-3 flex flex-wrap items-center justify-between gap-3 text-muted-foreground text-sm">
<p>
Folders are read-only. When a Bot needs to write, the desktop app asks
you first.
</p>
<div className="flex items-center gap-3">
<Button
disabled={!connected || stopping}
onClick={onStop}
size="sm"
variant="outline"
>
{stopping ? "Stopping…" : "Stop folder access"}
</Button>
<Link className="underline" to="/admin/audit">
View audit
</Link>
</div>
</div>
</PageSection>
);
}
function FolderGrantList({
botId,
grants,
onRevoke,
pending,
revokingGrantId,
}: {
botId: string;
grants: HostFolderGrant[];
onRevoke: (grantId: string) => void;
pending: HostAccessPendingOperation[];
revokingGrantId: string | null;
}) {
const botGrants = grants.filter(
(grant) => grant.botId === botId && !grant.revoked,
);
const botPending = pending.filter((request) => request.botId === botId);
if (botGrants.length === 0 && botPending.length === 0) return null;
return (
<div className="mt-2 flex flex-col gap-2">
{botGrants.map((grant) => (
<div
className="flex flex-wrap items-center justify-between gap-2 rounded-md border border-border bg-background px-3 py-2"
key={grant.id}
>
<div className="min-w-0">
<p className="truncate font-medium text-sm">{grant.displayName}</p>
<p className="text-muted-foreground text-xs">
{ownerLabel(grant)} · Read-only
</p>
</div>
<Button
disabled={revokingGrantId === grant.id}
onClick={() => onRevoke(grant.id)}
size="sm"
variant="ghost"
>
{revokingGrantId === grant.id ? "Revoking…" : "Revoke"}
</Button>
</div>
))}
{botPending.map((request) => (
<div
className="rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-sm"
key={request.operationId}
>
{pendingLabel(request)} from {ownerLabel(request)}
{request.displayName ? ` for ${request.displayName}` : ""}.
</div>
))}
</div>
);
}
function summaryFor(
botId: string,
grants: HostFolderGrant[],
pending: HostAccessPendingOperation[],
) {
const active = grants.filter(
(grant) => grant.botId === botId && !grant.revoked,
).length;
const waiting = pending.filter((request) => request.botId === botId).length;
const parts = [];
if (active > 0)
parts.push(`${active} read-only ${active === 1 ? "folder" : "folders"}`);
if (waiting > 0)
parts.push(`${waiting} pending ${waiting === 1 ? "request" : "requests"}`);
return parts.length > 0 ? parts.join(" · ") : "No folders approved.";
}
function ownerLabel(grant: { ownerName?: string; ownerEmail?: string }) {
return grant.ownerName ?? grant.ownerEmail ?? "the desktop owner";
}
function pendingLabel(request: HostAccessPendingOperation) {
switch (request.kind) {
case "write_file":
return "File change waiting for approval or to finish";
case "run_command":
return "Command waiting for approval or to finish";
case "list_files":
return "Listing files";
case "read_file":
return "Reading a file";
case "cancel":
case "stop":
return "Stopping folder work";
default:
return "Folder access waiting for approval";
}
}