Skip to content

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.

Make and manage coworkers in dialogs (#317)

Guido Vizoso33b3f60f3c71
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b4876146..efa50060 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,32 @@ Newest first. `Unreleased` is what is on `main` and not yet tagged.
## Unreleased
+### Coworkers are made in a wizard and managed in a dialog
+
+Creating a coworker is now a three-step wizard — who it is, who may see it, then where it runs,
+with **Built in** offered only when the deployment actually has a managed Bot to run it on.
+Managing one is a dialog opened from wherever the coworker appears, with sections for its profile
+(each field edited in place), what it may reach, its connection, handoff grants, routines, and the
+hide/duplicate/delete verbs — usable on a phone, where the old side panel hid most of this. The
+panel beside a conversation slims down to who-you-are-talking-to plus two buttons: start a new
+channel, or open that dialog.
+
+### Routines live on each coworker
+
+The sidebar's global Routines entry is gone; a coworker's routines are a section of its own dialog,
+since a routine is something *it* carries out. The `/routines` page still answers direct links.
+Each routine row now wears its state as chips — the channel it posts to, how the last run went, and
+either the next run, **Paused**, or **Due** when a firing is waiting on the sweep (which used to
+render as "Next 5 hours ago").
+
+### A built-in coworker is no longer asked for credentials it will never need
+
+A coworker running on the deployment's own Bot was nagged for a callback token and shown an
+endpoint form. Its connection tab now says what is true — it runs here, nothing to connect, nothing
+to authenticate. In the same spirit, the handoff panel explains once when a coworker cannot hand
+work on (it runs as its own agent, outside this deployment's loop) instead of offering switches the
+server can only refuse; its existing grants stay visible so they can still be revoked.
+
### A hop the boundary refused now names the Bot that was refused
The audit page renders its Bot column from `payload.bot` and nothing else. `agent.handoff_offered`
@@ -16,6 +42,7 @@ refused, a hop retried, and a hop that failed for good — were not, so they sho
Bot belongs. Those are the rows somebody actually opens the trail for: a hop that happened is visible
in the transcript anyway, and a refused or lost one is visible nowhere else. All four now name the
asking Bot, exactly as the accepted pair and `agent.escalated` already did.
+
### A failed tool refresh no longer leaves a connector offering nothing
Refreshing a connector's tools replaced the list with a delete and then an insert, as two separate
@@ -26,6 +53,7 @@ once, every grant an administrator had made was silently un-offered, and the Bot
none of that vendor's tools. Nothing brought them back until somebody read the error on the Plugins
page and pressed Refresh. The two statements are now one, so a bad refresh is recorded and the tools
already held are left alone, which is what the code always claimed to do.
+
### A rule tried in dry-run now says what it would have refused a Bot's tools
`dry-run` exists so a boundary can be measured against live traffic before it starts refusing
@@ -36,6 +64,7 @@ about `mcp.server`, `mcp.tool` or `mcp.effect` therefore looked inert, and enfor
refusing Bots with nothing in the trail to have warned anybody. A refused tool call is now recorded
whatever the mode does with it, carrying `carriedOut` so a reader can tell a call this deployment
stopped from one dry-run recorded and let past. Enforcing deployments behave exactly as before.
+
### A policy dry-run no longer counts a failed action twice, or invents a change it did not make
Testing a boundary against recent history replayed three kinds of audit row, and one of them is a
@@ -45,6 +74,7 @@ carries a refused action out, so a refused action can fail too — and its two r
decision row saying "refused" and the failure row reading as "allowed", so a candidate policy that
refused it identically was reported as a new refusal it never introduced. The replay now scores each
action once, from the row that recorded its decision.
+
### A message no longer routes to a specialist because a longer word contained a connector's name
When the intent router falls back — it is unreachable, or it declines — and exactly one coworker can
@@ -53,6 +83,7 @@ substring, so "how do I deal with a slacker" matched the **slack** connector and
giraffe) matched **jira**: a message naming neither system was pinned, for the life of the thread,
to a specialist that could not answer it. A connector's name now has to appear on a word boundary,
so a system named on its own still routes and one buried inside another word does not.
+
### The audit page no longer says "Allowed" about six kinds of refusal
A hop one Bot was not allowed to make, an endpoint this deployment would not dial, a rotation the
@@ -62,6 +93,7 @@ attempts and a question that reached nobody, which are "Did not happen" rather t
page recognised six refusal types and the six added since were never added to it. Refusals now read
as refusals, the two saved views are built from the same lists the rows are labelled from, and a
refusal added later is added in one place or in none.
+
### A conversation deleted while a server was reconnecting no longer lingers on the screen
Announcements between servers travel as Postgres notifications, which reach whoever is subscribed at
@@ -75,6 +107,7 @@ showing a conversation that had been deleted until the page was reloaded.
A server now tells the browsers it is holding to refetch when its subscription is re-established.
Nothing to configure, and no change for a deployment whose database connection never drops.
+
### A Bot's answer comes back to the conversation that asked
**This reverses what 0.0.5 shipped.** The 0.0.5 notes below say the asking Bot does not relay text
@@ -162,6 +195,7 @@ cluster and is not empty is now refused with a sentence naming the mount to use
Reported by [@jerelvelarde](https://github.com/CopilotKit/OpenBot/issues/269) with the container logs
for both mount paths, which is what made the two failure modes separable.
+
### A sign-in a site opens in a new window is shown, and can be clicked
A Bot's browser was bound to the page it launched with, and to nothing the site opened afterwards.
@@ -177,6 +211,7 @@ afterwards with the same "take a new snapshot" it already gives after a navigati
cannot act on the wrong document.
Nothing to configure.
+
### Stopping a Bot's computer stops it, and the person watching is told
A computer somebody stopped came back up on its own about a second later, and reset did the same. The
@@ -336,6 +371,7 @@ uses. It still cannot address another pod, a node, or a cloud metadata endpoint.
destination and so permitted everything. That rule now covers the API server alone, and
`networkPolicy.kubernetesApiCidr` narrows it to your cluster's service range; left empty it stays as
it was, because a chart cannot know that range.
+
### Taking the wheel stops the Bot's shell, not just its clicks
While a person held the wheel the Bot was refused on the page, and not in the shell. `/exec` and a
@@ -350,6 +386,7 @@ to be able to say what it was doing.
Nothing to configure. A Bot that acts during a takeover gets the refusal it already got for a click,
and the trail records the attempt and the failure the same way.
+
### A computer that was suspended once suspends again
Scale-to-zero worked once per Bot. A computer suspended, resumed, used and then left alone again was
@@ -366,6 +403,7 @@ the same clock the offer runs on, so a Bot cannot come back round as idle until
Nothing to configure, and the sweep already runs on a schedule. A deployment where each Bot has its
own computer stops paying for browsers that were used once.
+
### A Bot's egress proxy is reachable on Kubernetes, or the install is refused
The chart named no egress variable anywhere, so a Helm deployment read the per-Bot proxy settings
@@ -508,6 +546,7 @@ unknown session means "no opinion" and skips the generation check, so on exactly
shape it was written for, the check that stops a ref from a replaced computer resolving against a
live one was silently absent. It now asks the supervisor when it does not know, by listing rather
than by ensuring, so asking never starts a computer that had stopped.
+
### A routing trail says why a message was not routed, not only that it was not
Every untagged message writes a `channel.routed` row, and that row carried `fallback: true` for two
@@ -599,6 +638,7 @@ credential is refused rather than quietly attached to fail on its next call.
Curated servers keep working as they did. Their URL comes from the catalogue rather than the
request, and a per-instance hostname is matched against the vendor's own anchored pattern before
anything is stored, so re-adding one cannot point it at an address of the caller's choosing.
+
### A configured egress proxy reaches the browser that uses it
`EGRESS_PROXY_DEFAULT` and `EGRESS_PROXY_<BOT>` were documented as the way to give a Bot a stable
@@ -620,6 +660,7 @@ given them. It is optional, so a deployment with no proxy is unchanged, and giti
proxy URL can carry a password.
**Move these two out of `.env` and into `egress.env`.** In `.env` they reach no process.
+
### Screens without a conversation stop polling for a Bot that does not exist
Every surface asks which components its Bot holds, and asks again every few seconds so a revoked
@@ -634,6 +675,7 @@ that matters is invisible.
The grant queries now wait for a surface to declare a real Bot, and simply do not run while the
placeholder holds. Conversation surfaces — the Bot page, channels — declare one and are unchanged.
+
### A rule can be tested against history before it is saved
A boundary was written blind: an administrator typed a CEL rule, saved it, and learned what it
@@ -713,6 +755,7 @@ this port has to reach it another way**, which is what publishing it on every in
This does not reach back in time. A deployment that has been running with the two on one network
should assume a Bot could have read or written the database, and look at the trail with that in
mind.
+
### A credential in an MCP server address is refused in the query and the fragment too
Refusing `https://user:[email protected]/mcp` closed the userinfo spelling of a credential in the
@@ -739,6 +782,7 @@ beside `metadata.google.internal`, and it carries a dot and none of the suffixes
it read as an ordinary vendor name. The long spelling was only ever refused incidentally, by the
`.internal` rule. Both are now named, so the address this check was written for is refused on purpose
rather than by luck.
+
### A curated MCP server is pointed at its own kind of credential too
Adding a server by URL was made to check which credential it is being pointed at. Adding one from the
@@ -1012,6 +1056,7 @@ one they are, so those match too.
No configuration changes and nothing is stored differently; a deployment that was already on the
light theme sees no difference at all.
+
### `start.sh` refuses a port that answers but is not OpenBot
The startup checks asked whether a port answered, and treated that as proof the port belonged to this
@@ -1076,6 +1121,7 @@ the decision row is written, so an action somebody tried to take still appears o
**A deployment may see refusals it did not see before.** That is the point: those are the actions that
were being carried out without the boundary seeing what they touched. A Bot that meets one takes a
fresh snapshot and continues.
+
### A package ships its skills, so tool selection works on a clone
Tool selection narrows a Bot's tools to the ones its matching skills declare, and a deployment starts
diff --git a/app/src/components/agents/agent-dialog.tsx b/app/src/components/agents/agent-dialog.tsx
new file mode 100644
index 00000000..bfc60023
--- /dev/null
+++ b/app/src/components/agents/agent-dialog.tsx
@@ -0,0 +1,824 @@
+import {
+ IconAdjustments,
+ IconArrowsExchange,
+ IconClock,
+ IconPencil,
+ IconPlugConnected,
+ IconPuzzle,
+ IconUser,
+} from "@tabler/icons-react";
+import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
+import { useNavigate } from "@tanstack/react-router";
+import { useState } from "react";
+import type { ZodType } from "zod";
+import { AbstractAvatar } from "@/components/agents/abstract-avatar";
+import { CallbackTokenPanel } from "@/components/agents/callback-token-panel";
+import { HandoffPanel } from "@/components/agents/handoff-panel";
+import { RoutinesList } from "@/components/routines/routines-list";
+import { Button } from "@/components/ui/button";
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from "@/components/ui/dialog";
+import {
+ Empty,
+ EmptyDescription,
+ EmptyHeader,
+ EmptyTitle,
+} from "@/components/ui/empty";
+import { Input } from "@/components/ui/input";
+import {
+ Item,
+ ItemActions,
+ ItemContent,
+ ItemDescription,
+ ItemTitle,
+} from "@/components/ui/item";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@/components/ui/select";
+import {
+ Sidebar,
+ SidebarContent,
+ SidebarGroup,
+ SidebarGroupContent,
+ SidebarHeader,
+ SidebarMenu,
+ SidebarMenuButton,
+ SidebarMenuItem,
+ SidebarProvider,
+} from "@/components/ui/sidebar";
+import { Skeleton } from "@/components/ui/skeleton";
+import { Textarea } from "@/components/ui/textarea";
+import {
+ type AgentFormValues,
+ agentFormSchema,
+ agentInputFrom,
+} from "@/lib/agents/form";
+import {
+ deleteAgentMutationOptions,
+ duplicateAgentMutationOptions,
+ setAgentHiddenMutationOptions,
+ updateAgentMutationOptions,
+} from "@/lib/agents/mutations";
+import { type AgentProfile, agentQueryOptions } from "@/lib/agents/queries";
+import { agentPluginsQueryOptions } from "@/lib/plugins/queries";
+import { readToolName } from "@/lib/plugins/tool-name";
+
+/**
+ * A coworker, in a dialog with its own sidebar.
+ *
+ * The agents screen used to slide this in as a side panel; a profile carries enough distinct
+ * concerns — who it is, where it runs, what it may hand work to, and what can be done to it — that
+ * a single scrolling column buried the later ones. Each concern is a section here, and the sidebar
+ * is the map.
+ */
+export function AgentDialog({
+ agentId,
+ open,
+ onClose,
+}: {
+ /** Which coworker to show. Null renders nothing but keeps the dialog mounted for its exit. */
+ agentId: string | null;
+ open: boolean;
+ onClose: () => void;
+}) {
+ return (
+ <Dialog onOpenChange={(next) => !next && onClose()} open={open}>
+ {/* p-0/overflow-hidden hands the popup's rounding to the sidebar; wider than the default
+ dialog because it holds a two-pane layout, which is the stated reason to deviate. */}
+ {/* Tall enough that General's rows and its Delete sit on screen together; the popup's own
+ max-h-[85svh] still caps it on a short display, where the main pane scrolls. */}
+ <DialogContent className="overflow-hidden p-0 md:max-h-[680px] md:max-w-[700px] lg:max-w-[800px]">
+ {/* Keyed by coworker so the section and edit state never carry over from another one. */}
+ {agentId ? <AgentDialogBody agentId={agentId} key={agentId} /> : null}
+ </DialogContent>
+ </Dialog>
+ );
+}
+
+const SECTIONS = [
+ { id: "general", name: "General", icon: IconUser },
+ { id: "access", name: "Access", icon: IconPuzzle },
+ { id: "connection", name: "Connection", icon: IconPlugConnected },
+ { id: "handoff", name: "Handoff", icon: IconArrowsExchange },
+ { id: "routines", name: "Routines", icon: IconClock },
+ { id: "manage", name: "Manage", icon: IconAdjustments },
+] as const;
+
+type SectionId = (typeof SECTIONS)[number]["id"];
+
+function AgentDialogBody({ agentId }: { agentId: string }) {
+ const [section, setSection] = useState<SectionId>("general");
+ const agent = useQuery(agentQueryOptions(agentId));
+
+ if (agent.isPending) {
+ return (
+ <div className="flex h-[640px] max-h-[80svh] flex-col gap-4 p-6">
+ <Skeleton className="h-6 w-44" />
+ <Skeleton className="h-4 w-full" />
+ <Skeleton className="h-4 w-2/3" />
+ </div>
+ );
+ }
+ if (agent.error || !agent.data) {
+ return (
+ <p className="p-6 text-sm text-destructive" role="alert">
+ Could not load this coworker.
+ </p>
+ );
+ }
+ const profile = agent.data;
+ const active = SECTIONS.find((candidate) => candidate.id === section);
+
+ return (
+ <>
+ <DialogTitle className="sr-only">{profile.name}</DialogTitle>
+ {/* min-h-full overrides the provider's own min-h-svh, which is sized for a page. */}
+ <SidebarProvider className="min-h-full items-start">
+ <Sidebar className="hidden md:flex" collapsible="none">
+ {/* Who this dialog is about, said once here rather than repeated per section. */}
+ <SidebarHeader className="flex-row items-center gap-3 p-4">
+ <AbstractAvatar
+ name={profile.name}
+ seed={profile.avatarSeed}
+ size={36}
+ />
+ <div className="flex min-w-0 flex-col">
+ <span className="truncate text-sm font-medium">
+ {profile.name}
+ </span>
+ <span className="truncate text-xs text-muted-foreground">
+ {profile.title}
+ </span>
+ </div>
+ </SidebarHeader>
+ <SidebarContent className="mt-2">
+ <SidebarGroup>
+ <SidebarGroupContent>
+ <SidebarMenu className="gap-px">
+ {SECTIONS.map((item) => (
+ <SidebarMenuItem key={item.id}>
+ <SidebarMenuButton
+ isActive={item.id === section}
+ onClick={() => setSection(item.id)}
+ >
+ <item.icon />
+ <span>{item.name}</span>
+ </SidebarMenuButton>
+ </SidebarMenuItem>
+ ))}
+ </SidebarMenu>
+ </SidebarGroupContent>
+ </SidebarGroup>
+ </SidebarContent>
+ </Sidebar>
+ <main className="flex h-[640px] max-h-[80svh] flex-1 flex-col overflow-hidden">
+ {/*
+ * The sidebar hides below md, and without this strip that left the sections unreachable
+ * on a phone: the dialog opened on General and nothing could leave it. A scrollable row
+ * of the same sections, shown only where the sidebar is not. The identity the sidebar
+ * header carries rides along, with room kept for the popup's close button.
+ */}
+ <div className="flex shrink-0 flex-col gap-2 border-b border-border p-3 pr-12 md:hidden">
+ <div className="flex items-center gap-2">
+ <AbstractAvatar
+ name={profile.name}
+ seed={profile.avatarSeed}
+ size={28}
+ />
+ <span className="truncate text-sm font-medium">
+ {profile.name}
+ </span>
+ </div>
+ <div className="flex gap-1 overflow-x-auto">
+ {SECTIONS.map((item) => (
+ <Button
+ className="shrink-0"
+ key={item.id}
+ onClick={() => setSection(item.id)}
+ size="sm"
+ variant={item.id === section ? "secondary" : "ghost"}
+ >
+ <item.icon />
+ {item.name}
+ </Button>
+ ))}
+ </div>
+ </div>
+ <header className="flex h-14 shrink-0 items-center gap-2 px-6">
+ <h2 className="text-sm font-medium">{active?.name}</h2>
+ </header>
+ <div className="flex flex-1 flex-col gap-6 overflow-y-auto px-6 pb-6">
+ {section === "general" ? (
+ <GeneralSection agentId={agentId} profile={profile} />
+ ) : section === "access" ? (
+ <AccessSection agentId={agentId} />
+ ) : section === "connection" ? (
+ <ConnectionSection agentId={agentId} profile={profile} />
+ ) : section === "handoff" ? (
+ <HandoffPanel agentId={agentId} />
+ ) : section === "routines" ? (
+ <RoutinesList agentId={agentId} embedded />
+ ) : (
+ <ManageSection agentId={agentId} profile={profile} />
+ )}
+ </div>
+ </main>
+ </SidebarProvider>
+ </>
+ );
+}
+
+function GeneralSection({
+ agentId,
+ profile,
+}: {
+ agentId: string;
+ profile: AgentProfile;
+}) {
+ const queryClient = useQueryClient();
+ const navigate = useNavigate();
+ const updateAgent = useMutation(updateAgentMutationOptions(queryClient));
+
+ /*
+ * One field at a time, over the whole update endpoint: the API takes the full profile, so the
+ * unchanged fields ride along as they are on screen. The empty key means "keep the current one".
+ */
+ const save = (patch: Partial<AgentFormValues>) =>
+ updateAgent.mutateAsync({
+ agentId,
+ input: agentInputFrom({
+ name: profile.name,
+ title: profile.title,
+ roleDescription: profile.roleDescription,
+ visibility: profile.visibility,
+ endpoint: profile.endpoint ?? "",
+ authValue: "",
+ ...patch,
+ }),
+ });
+
+ return (
+ <>
+ {/* Each stands on its own — muted, not bg-card, which is invisible against a popup — and
+ each edits in place: the field somebody wants to change is the only one that opens. */}
+ <div className="flex flex-col gap-2">
+ <EditableTextItem
+ canManage={profile.canManage}
+ label="Name"
+ onSave={(name) => save({ name })}
+ schema={agentFormSchema.shape.name}
+ value={profile.name}
+ />
+ <EditableTextItem
+ canManage={profile.canManage}
+ label="Title"
+ onSave={(title) => save({ title })}
+ schema={agentFormSchema.shape.title}
+ value={profile.title}
+ />
+ <EditableTextItem
+ canManage={profile.canManage}
+ label="Role"
+ multiline
+ onSave={(roleDescription) => save({ roleDescription })}
+ schema={agentFormSchema.shape.roleDescription}
+ value={profile.roleDescription}
+ />
+ <VisibilityItem
+ canManage={profile.canManage}
+ onSave={(visibility) => save({ visibility })}
+ value={profile.visibility}
+ />
+ {profile.systemOwned ? (
+ <Item variant="muted">
+ <ItemContent>
+ <ItemTitle>System owned</ItemTitle>
+ <ItemDescription>
+ Ships with this deployment rather than belonging to a person.
+ </ItemDescription>
+ </ItemContent>
+ </Item>
+ ) : null}
+ </div>
+
+ <Item variant="muted">
+ <ItemContent>
+ <ItemTitle>Start channel</ItemTitle>
+ <ItemDescription>
+ Open a new channel with this coworker.
+ </ItemDescription>
+ </ItemContent>
+ <ItemActions>
+ <Button
+ onClick={() =>
+ void navigate({
+ search: { agent: agentId },
+ to: "/channel/new",
+ })
+ }
+ size="sm"
+ >
+ Start
+ </Button>
+ </ItemActions>
+ </Item>
+ </>
+ );
+}
+
+/**
+ * One fact about the coworker, edited in place.
+ *
+ * Only the field somebody wants to change opens: Edit swaps this item — and this item alone — for
+ * its input, validated against the same limits the server enforces, and Save writes just it back.
+ */
+function EditableTextItem({
+ label,
+ value,
+ canManage,
+ multiline = false,
+ schema,
+ onSave,
+}: {
+ label: string;
+ value: string;
+ canManage: boolean;
+ /** A textarea rather than an input, for the field that is a paragraph. */
+ multiline?: boolean;
+ /** The field's slice of the shared form contract, so errors match the server's limits. */
+ schema: ZodType<string>;
+ onSave: (draft: string) => Promise<unknown>;
+}) {
+ const [editing, setEditing] = useState(false);
+ const [draft, setDraft] = useState(value);
+ const [saving, setSaving] = useState(false);
+ const [error, setError] = useState<string | null>(null);
+
+ const close = () => {
+ setEditing(false);
+ setError(null);
+ };
+ const submit = async () => {
+ const parsed = schema.safeParse(draft);
+ if (!parsed.success) {
+ setError(parsed.error.issues[0]?.message ?? "That value does not fit.");
+ return;
+ }
+ setSaving(true);
+ try {
+ await onSave(parsed.data);
+ close();
+ } catch (failure) {
+ setError(failure instanceof Error ? failure.message : "Could not save.");
+ } finally {
+ setSaving(false);
+ }
+ };
+
+ if (!editing) {
+ return (
+ <Item variant="muted">
+ <ItemContent>
+ <ItemTitle>{label}</ItemTitle>
+ </ItemContent>
+ <ItemActions className="min-w-0">
+ <span
+ className={`text-right text-sm text-muted-foreground ${
+ multiline ? "line-clamp-2 whitespace-pre-wrap" : "truncate"
+ }`}
+ >
+ {value}
+ </span>
+ {canManage ? (
+ <Button
+ aria-label={`Edit ${label.toLowerCase()}`}
+ onClick={() => {
+ setDraft(value);
+ setEditing(true);
+ }}
+ size="icon-sm"
+ variant="ghost"
+ >
+ <IconPencil />
+ </Button>
+ ) : null}
+ </ItemActions>
+ </Item>
+ );
+ }
+
+ return (
+ <Item variant="muted">
+ <ItemContent>
+ <ItemTitle>{label}</ItemTitle>
+ {multiline ? (
+ <Textarea
+ autoFocus
+ onChange={(event) => setDraft(event.target.value)}
+ rows={4}
+ value={draft}
+ />
+ ) : (
+ <Input
+ autoFocus
+ onChange={(event) => setDraft(event.target.value)}
+ onKeyDown={(event) => {
+ if (event.key === "Enter") {
+ event.preventDefault();
+ void submit();
+ }
+ }}
+ value={draft}
+ />
+ )}
+ {error ? (
+ <p className="text-sm text-destructive" role="alert">
+ {error}
+ </p>
+ ) : null}
+ <div className="mt-1 flex gap-2">
+ <Button disabled={saving} onClick={() => void submit()} size="sm">
+ {saving ? "Saving…" : "Save"}
+ </Button>
+ <Button disabled={saving} onClick={close} size="sm" variant="outline">
+ Cancel
+ </Button>
+ </div>
+ </ItemContent>
+ </Item>
+ );
+}
+
+/**
+ * Visibility is two named choices, so it edits as a select that writes on pick — no open state and
+ * no Save, because there is no draft worth holding: the pick is the whole of the change.
+ */
+function VisibilityItem({
+ value,
+ canManage,
+ onSave,
+}: {
+ value: AgentProfile["visibility"];
+ canManage: boolean;
+ onSave: (visibility: AgentProfile["visibility"]) => Promise<unknown>;
+}) {
+ const [saving, setSaving] = useState(false);
+ const [error, setError] = useState<string | null>(null);
+
+ return (
+ <Item variant="muted">
+ <ItemContent>
+ <ItemTitle>Visibility</ItemTitle>
+ <ItemDescription>
+ {value === "private"
+ ? "Only you can see it and start channels with it."
+ : "Everyone in the deployment can find and use it."}
+ </ItemDescription>
+ {error ? (
+ <p className="text-sm text-destructive" role="alert">
+ {error}
+ </p>
+ ) : null}
+ </ItemContent>
+ <ItemActions>
+ {canManage ? (
+ <Select
+ disabled={saving}
+ // The label map, so the closed trigger says "Private" rather than the raw value.
+ items={{ private: "Private", public: "Public" }}
+ onValueChange={async (next) => {
+ if (next === value) return;
+ setError(null);
+ setSaving(true);
+ try {
+ await onSave(next as AgentProfile["visibility"]);
+ } catch (failure) {
+ setError(
+ failure instanceof Error
+ ? failure.message
+ : "Could not save.",
+ );
+ } finally {
+ setSaving(false);
+ }
+ }}
+ value={value}
+ >
+ <SelectTrigger className="w-28">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="private">Private</SelectItem>
+ <SelectItem value="public">Public</SelectItem>
+ </SelectContent>
+ </Select>
+ ) : (
+ <span className="text-sm text-muted-foreground">
+ {value === "private" ? "Private" : "Public"}
+ </span>
+ )}
+ </ItemActions>
+ </Item>
+ );
+}
+
+/** "google-drive" as "Google Drive": the connector key, said the way a person would. */
+function connectorName(key: string): string {
+ return key
+ .split(/[-_]/)
+ .filter(Boolean)
+ .map((word) => word[0]?.toUpperCase() + word.slice(1))
+ .join(" ");
+}
+
+/**
+ * What this coworker may reach when it works: its granted connectors, one row each, and its skills.
+ *
+ * Read from the same snapshot the runtime offers the Bot, so this shows what a run would actually
+ * hold rather than a second opinion. Read-only on purpose — granting is an administrator's, made on
+ * the Plugins screens, and a row of switches here would be a second place for the same decision.
+ */
+function AccessSection({ agentId }: { agentId: string }) {
+ const plugins = useQuery(agentPluginsQueryOptions(agentId));
+
+ if (plugins.isPending) return null;
+ if (plugins.error || !plugins.data) {
+ return (
+ <p className="text-sm text-destructive" role="alert">
+ What this coworker may reach could not be loaded.
+ </p>
+ );
+ }
+
+ /* One row per connector, carrying what a person recognises: the tools' names, not their count. */
+ const connectors = new Map<string, string[]>();
+ for (const tool of plugins.data.tools) {
+ const key = tool.ref.split("/")[0] ?? tool.ref;
+ let label = readToolName(tool.toolName).label;
+ /*
+ * Vendors prefix every tool with their own name — "Notion create pages" — which next to a row
+ * already titled Notion reads as a stutter. Stripped only as a leading word, and re-cased, so
+ * "Notion search" becomes "Search" while "Search notion pages" is left alone.
+ */
+ const prefix = `${key.toLowerCase()} `;
+ if (label.toLowerCase().startsWith(prefix)) {
+ const rest = label.slice(prefix.length);
+ label = rest ? rest[0]?.toUpperCase() + rest.slice(1) : label;
+ }
+ const labels = connectors.get(key) ?? [];
+ labels.push(label);
+ connectors.set(key, labels);
+ }
+ const skills = plugins.data.skills;
+
+ if (connectors.size === 0 && skills.length === 0) {
+ return (
+ <Empty className="h-[180px] border border-dashed">
+ <EmptyHeader>
+ <EmptyTitle className="text-muted-foreground">
+ Nothing granted yet
+ </EmptyTitle>
+ <EmptyDescription>
+ An administrator grants connectors and skills from the Plugins
+ screens. Until then this coworker can converse, and nothing more.
+ </EmptyDescription>
+ </EmptyHeader>
+ </Empty>
+ );
+ }
+
+ return (
+ <>
+ <p className="text-sm text-muted-foreground">
+ What this coworker may reach when it works. Granted by an administrator
+ on the Plugins screens; anything not listed is refused when called.
+ </p>
+ <div className="flex flex-col gap-2">
+ {[...connectors.entries()].map(([key, labels]) => (
+ <Item key={key} variant="muted">
+ <ItemContent>
+ <ItemTitle>{connectorName(key)}</ItemTitle>
+ <ItemDescription>
+ {labels.slice(0, 4).join(", ")}
+ {labels.length > 4 ? ` and ${labels.length - 4} more` : ""}
+ </ItemDescription>
+ </ItemContent>
+ <ItemActions>
+ <span className="text-sm text-muted-foreground tabular-nums">
+ {labels.length} {labels.length === 1 ? "tool" : "tools"}
+ </span>
+ </ItemActions>
+ </Item>
+ ))}
+ {skills.map((skill) => (
+ <Item key={skill.slug} variant="muted">
+ <ItemContent>
+ <ItemTitle>{skill.title}</ItemTitle>
+ <ItemDescription>{skill.summary}</ItemDescription>
+ </ItemContent>
+ <ItemActions>
+ <span className="text-sm text-muted-foreground">Skill</span>
+ </ItemActions>
+ </Item>
+ ))}
+ </div>
+ </>
+ );
+}
+
+function ConnectionSection({
+ agentId,
+ profile,
+}: {
+ agentId: string;
+ profile: AgentProfile;
+}) {
+ /*
+ * A built-in coworker is done the moment it exists: it runs on the deployment's own Bot, whose
+ * process already holds the deployment's tool credential, so its tool calls authenticate with no
+ * setup. Showing it the endpoint and the callback-token panel told the person the opposite —
+ * an internal address they never typed, and a credential they were never supposed to need.
+ */
+ if (!profile.endpoint || profile.builtIn) {
+ return (
+ <p className="text-sm text-muted-foreground">
+ Runs on this deployment's own Bot. Nothing to connect and nothing to
+ authenticate: its tool calls are covered by the deployment's own
+ credential.
+ </p>
+ );
+ }
+ return (
+ <>
+ <section className="grid gap-2">
+ <h2 className="text-xs font-medium uppercase tracking-wide text-muted-foreground">
+ Endpoint
+ </h2>
+ <p className="break-all font-mono text-sm">{profile.endpoint}</p>
+ </section>
+ {profile.canManage ? (
+ <CallbackTokenPanel
+ agentId={agentId}
+ hasToken={profile.hasCallbackToken}
+ />
+ ) : null}
+ </>
+ );
+}
+
+function ManageSection({
+ agentId,
+ profile,
+}: {
+ agentId: string;
+ profile: AgentProfile;
+}) {
+ const queryClient = useQueryClient();
+ const navigate = useNavigate();
+ const [confirmingDelete, setConfirmingDelete] = useState(false);
+ const setHidden = useMutation(setAgentHiddenMutationOptions(queryClient));
+ const duplicateAgent = useMutation(
+ duplicateAgentMutationOptions(queryClient),
+ );
+ const deleteAgent = useMutation(deleteAgentMutationOptions(queryClient));
+ const actionError = setHidden.error ?? duplicateAgent.error;
+
+ return (
+ <>
+ {/* The same gap the General items keep, so the two screens read as one list style. */}
+ <div className="flex flex-col gap-2">
+ <Item variant="muted">
+ <ItemContent>
+ <ItemTitle>{profile.hidden ? "Hidden" : "Hide"}</ItemTitle>
+ <ItemDescription>
+ {profile.hidden
+ ? "Hidden from your agents list. This changes nothing for anyone else."
+ : "Take it off your agents list. This changes nothing for anyone else."}
+ </ItemDescription>
+ </ItemContent>
+ <ItemActions>
+ <Button
+ disabled={setHidden.isPending}
+ onClick={async () => {
+ await setHidden.mutateAsync({
+ agentId,
+ hidden: !profile.hidden,
+ });
+ if (!profile.hidden)
+ await navigate({ search: {}, to: "/agents" });
+ }}
+ size="sm"
+ variant="outline"
+ >
+ {setHidden.isPending
+ ? profile.hidden
+ ? "Unhiding…"
+ : "Hiding…"
+ : profile.hidden
+ ? "Unhide"
+ : "Hide"}
+ </Button>
+ </ItemActions>
+ </Item>
+
+ <Item variant="muted">
+ <ItemContent>
+ <ItemTitle>Duplicate</ItemTitle>
+ <ItemDescription>
+ A copy of your own, with no key and no channels.
+ </ItemDescription>
+ </ItemContent>
+ <ItemActions>
+ <Button
+ disabled={duplicateAgent.isPending}
+ onClick={async () => {
+ const copy = await duplicateAgent.mutateAsync(agentId);
+ await navigate({ search: { agent: copy.id }, to: "/agents" });
+ }}
+ size="sm"
+ variant="outline"
+ >
+ {duplicateAgent.isPending ? "Duplicating…" : "Duplicate"}
+ </Button>
+ </ItemActions>
+ </Item>
+
+ {profile.canManage ? (
+ <Item variant="muted">
+ <ItemContent>
+ <ItemTitle>Delete</ItemTitle>
+ <ItemDescription>This cannot be undone.</ItemDescription>
+ </ItemContent>
+ <ItemActions>
+ <Button
+ onClick={() => setConfirmingDelete(true)}
+ size="sm"
+ variant="destructive"
+ >
+ Delete
+ </Button>
+ </ItemActions>
+ </Item>
+ ) : null}
+ </div>
+
+ {actionError ? (
+ <p className="text-sm text-destructive" role="alert">
+ {actionError.message}
+ </p>
+ ) : null}
+
+ {/* Stacked over the agent dialog: destroying something deserves its own moment, and the
+ question keeps the name in it so the wrong tab cannot delete the wrong coworker. */}
+ <Dialog
+ onOpenChange={(next) => !next && setConfirmingDelete(false)}
+ open={confirmingDelete}
+ >
+ <DialogContent
+ className="max-w-sm"
+ overlayClassName="bg-black/20 supports-backdrop-filter:backdrop-blur-sm"
+ >
+ <DialogHeader>
+ <DialogTitle>Delete {profile.name}?</DialogTitle>
+ <DialogDescription>This cannot be undone.</DialogDescription>
+ </DialogHeader>
+ {deleteAgent.error ? (
+ <p className="mt-4 text-sm text-destructive" role="alert">
+ {deleteAgent.error.message}
+ </p>
+ ) : null}
+ <DialogFooter className="mt-4">
+ <Button
+ onClick={() => setConfirmingDelete(false)}
+ size="sm"
+ variant="outline"
+ >
+ Cancel
+ </Button>
+ <Button
+ disabled={deleteAgent.isPending}
+ onClick={async () => {
+ await deleteAgent.mutateAsync(agentId);
+ await navigate({ search: {}, to: "/agents" });
+ }}
+ size="sm"
+ variant="destructive"
+ >
+ {deleteAgent.isPending ? "Deleting…" : "Delete"}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ </>
+ );
+}
diff --git a/app/src/components/agents/agent-fields.tsx b/app/src/components/agents/agent-fields.tsx
deleted file mode 100644
index 9035b838..00000000
--- a/app/src/components/agents/agent-fields.tsx
+++ /dev/null
@@ -1,284 +0,0 @@
-import { useForm } from "@tanstack/react-form";
-import { useState } from "react";
-import { Button } from "@/components/ui/button";
-import {
- Field,
- FieldError,
- FieldGroup,
- FieldLabel,
-} from "@/components/ui/field";
-import { Input } from "@/components/ui/input";
-import {
- Select,
- SelectContent,
- SelectGroup,
- SelectItem,
- SelectTrigger,
- SelectValue,
-} from "@/components/ui/select";
-import { Textarea } from "@/components/ui/textarea";
-import { type AgentFormValues, agentFormSchema } from "@/lib/agents/form";
-import {
- type ConnectionVerdict,
- testAgentConnection,
-} from "@/lib/agents/queries";
-
-export function AgentFields({
- defaultValues,
- hasAuth = false,
- submitLabel,
- onSubmit,
- error,
- onCancel,
-}: {
- defaultValues: AgentFormValues;
- /** Whether this coworker already has a key, so the field can say so without showing it. */
- hasAuth?: boolean;
- submitLabel: string;
- onSubmit: (values: AgentFormValues) => Promise<unknown>;
- error?: Error | null;
- onCancel?: () => void;
-}) {
- const form = useForm({
- defaultValues,
- validators: { onSubmit: agentFormSchema },
- onSubmit: async ({ value }) => {
- await onSubmit(value);
- },
- });
-
- const [connection, setConnection] = useState<ConnectionVerdict | null>(null);
- const [testing, setTesting] = useState(false);
-
- /** Test endpoint reachability from the server, which is what runs will use. */
- const testConnection = async (endpoint: string, key: string) => {
- setTesting(true);
- setConnection(null);
- try {
- setConnection(await testAgentConnection(endpoint, key));
- } finally {
- setTesting(false);
- }
- };
-
- return (
- <form
- noValidate
- onSubmit={(event) => {
- event.preventDefault();
- form.handleSubmit();
- }}
- >
- <FieldGroup>
- <form.Field name="name">
- {(field) => {
- const isInvalid =
- field.state.meta.isTouched && !field.state.meta.isValid;
- return (
- <Field data-invalid={isInvalid}>
- <FieldLabel htmlFor={field.name}>Name</FieldLabel>
- <Input
- aria-invalid={isInvalid}
- id={field.name}
- name={field.name}
- onBlur={field.handleBlur}
- onChange={(event) => field.handleChange(event.target.value)}
- placeholder="Expense Manager"
- value={field.state.value}
- />
- {isInvalid ? (
- <FieldError errors={field.state.meta.errors} />
- ) : null}
- </Field>
- );
- }}
- </form.Field>
- <form.Field name="title">
- {(field) => {
- const isInvalid =
- field.state.meta.isTouched && !field.state.meta.isValid;
- return (
- <Field data-invalid={isInvalid}>
- <FieldLabel htmlFor={field.name}>Title</FieldLabel>
- <Input
- aria-invalid={isInvalid}
- id={field.name}
- name={field.name}
- onBlur={field.handleBlur}
- onChange={(event) => field.handleChange(event.target.value)}
- placeholder="Finance Operations"
- value={field.state.value}
- />
- {isInvalid ? (
- <FieldError errors={field.state.meta.errors} />
- ) : null}
- </Field>
- );
- }}
- </form.Field>
- <form.Field name="roleDescription">
- {(field) => {
- const isInvalid =
- field.state.meta.isTouched && !field.state.meta.isValid;
- return (
- <Field data-invalid={isInvalid}>
- <FieldLabel htmlFor={field.name}>Role</FieldLabel>
- <Textarea
- aria-invalid={isInvalid}
- id={field.name}
- name={field.name}
- onBlur={field.handleBlur}
- onChange={(event) => field.handleChange(event.target.value)}
- placeholder="Review receipts, categorize expenses, and prepare reimbursement reports."
- rows={4}
- value={field.state.value}
- />
- {isInvalid ? (
- <FieldError errors={field.state.meta.errors} />
- ) : null}
- </Field>
- );
- }}
- </form.Field>
- <form.Field name="visibility">
- {(field) => (
- <Field>
- <FieldLabel htmlFor={field.name}>Visibility</FieldLabel>
- <Select
- onValueChange={(value) =>
- field.handleChange(value as AgentFormValues["visibility"])
- }
- value={field.state.value}
- >
- <SelectTrigger id={field.name}>
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- <SelectGroup>
- <SelectItem value="private">
- Private, only you can see it
- </SelectItem>
- <SelectItem value="public">
- Public, everybody can see it
- </SelectItem>
- </SelectGroup>
- </SelectContent>
- </Select>
- </Field>
- )}
- </form.Field>
- <form.Field name="endpoint">
- {(field) => {
- const isInvalid =
- field.state.meta.isTouched && !field.state.meta.isValid;
- return (
- <Field data-invalid={isInvalid}>
- <FieldLabel htmlFor={field.name}>
- Agent endpoint (optional)
- </FieldLabel>
- <div className="flex gap-2">
- <Input
- aria-invalid={isInvalid}
- id={field.name}
- name={field.name}
- onBlur={field.handleBlur}
- onChange={(event) => {
- setConnection(null);
- field.handleChange(event.target.value);
- }}
- placeholder="https://your-agent.example.com/ag-ui"
- value={field.state.value}
- />
- <Button
- disabled={!field.state.value || testing}
- onClick={() =>
- void testConnection(
- field.state.value,
- form.getFieldValue("authValue") ?? "",
- )
- }
- type="button"
- variant="outline"
- >
- {testing ? "Testing…" : "Test"}
- </Button>
- </div>
- {isInvalid ? (
- <FieldError errors={field.state.meta.errors} />
- ) : null}
- {connection ? (
- <p
- className={`text-sm ${connection.ok ? "text-muted-foreground" : "text-destructive"}`}
- role="status"
- >
- {connection.ok
- ? `It answered: ${connection.events.join(", ")}`
- : connection.reason}
- </p>
- ) : (
- <p className="text-muted-foreground text-sm">
- Leave empty to use the built-in Bot. Anything that speaks
- AG-UI works. This server dials your agent, so an agent on
- your own machine has to be reachable from here.
- </p>
- )}
- </Field>
- );
- }}
- </form.Field>
- <form.Field name="authValue">
- {(field) => (
- <Field>
- <FieldLabel htmlFor={field.name}>
- Key for that agent (optional)
- </FieldLabel>
- <Input
- autoComplete="off"
- id={field.name}
- name={field.name}
- onBlur={field.handleBlur}
- onChange={(event) => field.handleChange(event.target.value)}
- placeholder={
- hasAuth
- ? "A key is set. Type a new one to replace it."
- : "Bearer …"
- }
- // Never repopulated; `hasAuth` communicates that a key exists without exposing it.
- type="password"
- value={field.state.value}
- />
- <p className="text-muted-foreground text-sm">
- Sent as an <code>Authorization</code> header on every run, and
- kept in the credential vault. Leave empty to keep the current
- key.
- </p>
- </Field>
- )}
- </form.Field>
- </FieldGroup>
-
- {error ? (
- <p className="mt-4 text-sm text-destructive" role="alert">
- {error.message}
- </p>
- ) : null}
-
- <div className="mt-4 flex gap-2">
- <form.Subscribe
- selector={(state) => [state.canSubmit, state.isSubmitting]}
- >
- {([canSubmit, isSubmitting]) => (
- <Button disabled={!canSubmit || isSubmitting} type="submit">
- {isSubmitting ? "Saving…" : submitLabel}
- </Button>
- )}
- </form.Subscribe>
- {onCancel ? (
- <Button onClick={onCancel} type="button" variant="outline">
- Cancel
- </Button>
- ) : null}
- </div>
- </form>
- );
-}
diff --git a/app/src/components/agents/agent-profile.tsx b/app/src/components/agents/agent-profile.tsx
index f74555d6..311aa1d9 100644
--- a/app/src/components/agents/agent-profile.tsx
+++ b/app/src/components/agents/agent-profile.tsx
@@ -1,20 +1,10 @@
-import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
+import { useQuery } from "@tanstack/react-query";
import { useNavigate } from "@tanstack/react-router";
import { type ReactNode, useState } from "react";
import { AbstractAvatar } from "@/components/agents/abstract-avatar";
-import { AgentFields } from "@/components/agents/agent-fields";
-import { CallbackTokenPanel } from "@/components/agents/callback-token-panel";
-import { HandoffPanel } from "@/components/agents/handoff-panel";
+import { AgentDialog } from "@/components/agents/agent-dialog";
import { Button } from "@/components/ui/button";
-import { Separator } from "@/components/ui/separator";
import { Skeleton } from "@/components/ui/skeleton";
-import { agentInputFrom } from "@/lib/agents/form";
-import {
- deleteAgentMutationOptions,
- duplicateAgentMutationOptions,
- setAgentHiddenMutationOptions,
- updateAgentMutationOptions,
-} from "@/lib/agents/mutations";
import { agentQueryOptions } from "@/lib/agents/queries";
function Tag({ children }: { children: ReactNode }) {
@@ -44,33 +34,24 @@ function ProfileSkeleton() {
<Skeleton className="h-4 w-full" />
<Skeleton className="h-4 w-2/3" />
</div>
- <div className="flex flex-col gap-2">
- <Skeleton className="h-9 w-full" />
- <Skeleton className="h-9 w-full" />
- <Skeleton className="h-9 w-full" />
- </div>
+ <Skeleton className="h-9 w-full" />
</div>
);
}
+/**
+ * Who this coworker is, beside a conversation with it.
+ *
+ * A card, not a control panel: the panel answers "who am I talking to" — avatar, name, role — and
+ * everything that changes the coworker lives in its own dialog, opened from the one button here.
+ * It used to duplicate that dialog's whole surface (edit form, tokens, grants, delete), which made
+ * two places to maintain and a sidebar that scrolled past the conversation it sat beside.
+ */
export function AgentProfile({ agentId }: { agentId: string }) {
- const queryClient = useQueryClient();
+ /** The full dialog, opened over the chat rather than navigating away from it. */
+ const [managing, setManaging] = useState(false);
const navigate = useNavigate();
- // State is keyed by coworker id because this panel can remain open while its target changes.
- const [editingId, setEditingId] = useState<string | null>(null);
- const [confirmingDeleteId, setConfirmingDeleteId] = useState<string | null>(
- null,
- );
- const isEditing = editingId === agentId;
- const isConfirmingDelete = confirmingDeleteId === agentId;
-
const agent = useQuery(agentQueryOptions(agentId));
- const updateAgent = useMutation(updateAgentMutationOptions(queryClient));
- const duplicateAgent = useMutation(
- duplicateAgentMutationOptions(queryClient),
- );
- const setHidden = useMutation(setAgentHiddenMutationOptions(queryClient));
- const deleteAgent = useMutation(deleteAgentMutationOptions(queryClient));
if (agent.isPending) {
return <ProfileSkeleton />;
@@ -84,8 +65,6 @@ export function AgentProfile({ agentId }: { agentId: string }) {
}
const profile = agent.data;
- const actionError =
- duplicateAgent.error ?? setHidden.error ?? deleteAgent.error;
return (
<div className="flex w-full flex-col gap-6 p-8">
@@ -110,172 +89,38 @@ export function AgentProfile({ agentId }: { agentId: string }) {
</div>
</header>
- {isEditing ? (
- <AgentFields
- defaultValues={{
- name: profile.name,
- roleDescription: profile.roleDescription,
- title: profile.title,
- visibility: profile.visibility,
- endpoint: profile.endpoint ?? "",
- // The server never sends credentials back to the client.
- authValue: "",
- }}
- hasAuth={profile.hasAuth}
- error={updateAgent.error}
- onCancel={() => setEditingId(null)}
- onSubmit={async (values) => {
- await updateAgent.mutateAsync({
- agentId,
- input: agentInputFrom(values),
- });
- setEditingId(null);
- }}
- submitLabel="Save changes"
- />
- ) : (
- <section className="grid gap-2">
- <h2 className="text-xs font-medium uppercase tracking-wide text-muted-foreground">
- Role
- </h2>
- <p className="text-sm whitespace-pre-wrap text-pretty">
- {profile.roleDescription}
- </p>
- </section>
- )}
-
- {/*
- * Only for a coworker that runs somewhere else, and only for somebody who may change it.
- * The Bot in the box has no endpoint and nothing to authenticate as.
- */}
- {!isEditing && profile.endpoint && profile.canManage ? (
- <CallbackTokenPanel
- agentId={agentId}
- hasToken={profile.hasCallbackToken}
- />
- ) : null}
-
- {/*
- * Not while editing, for the same reason the panel above is not: the form owns the screen, and
- * these switches write immediately rather than on save, which would make one half of an open
- * form apply and the other half not.
- */}
- {isEditing ? null : <HandoffPanel agentId={agentId} />}
-
- {actionError ? (
- <p className="text-sm text-destructive" role="alert">
- {actionError.message}
+ <section className="grid gap-2">
+ <h2 className="text-xs font-medium uppercase tracking-wide text-muted-foreground">
+ Role
+ </h2>
+ <p className="text-sm whitespace-pre-wrap text-pretty">
+ {profile.roleDescription}
</p>
- ) : null}
-
- {isEditing ? null : (
- <div className="flex flex-col gap-2 w-full mt-6">
- <Button
- className="w-full text-sm!"
- onClick={async () => {
- await navigate({
- search: { agent: agentId },
- to: "/channel/new",
- });
- }}
- >
- Start channel
- </Button>
-
- <Button
- className="w-full text-sm!"
- disabled={duplicateAgent.isPending}
- onClick={async () => {
- const copy = await duplicateAgent.mutateAsync(agentId);
- await navigate({ search: { agent: copy.id }, to: "/agents" });
- }}
- variant="outline"
- >
- {duplicateAgent.isPending ? "Duplicating…" : "Duplicate"}
- </Button>
-
- <Button
- className="w-full text-sm!"
- disabled={setHidden.isPending}
- onClick={async () => {
- await setHidden.mutateAsync({
- agentId,
- hidden: !profile.hidden,
- });
- if (!profile.hidden)
- await navigate({ search: {}, to: "/agents" });
- }}
- variant="outline"
- >
- {setHidden.isPending
- ? profile.hidden
- ? "Unhiding…"
- : "Hiding…"
- : profile.hidden
- ? "Unhide"
- : "Hide"}
- </Button>
-
- {profile.hidden ? (
- <p className="-mt-1 text-xs text-muted-foreground">
- Hidden from your agents list. This changes nothing for anyone
- else.
- </p>
- ) : null}
+ </section>
- {profile.canManage ? (
- <Button
- className="w-full text-sm!"
- onClick={() => setEditingId(agentId)}
- variant="outline"
- >
- Edit
- </Button>
- ) : null}
-
- {profile.canManage ? (
- <>
- <Separator className="my-1" />
+ <div className="flex flex-col gap-2">
+ <Button
+ className="w-full text-sm!"
+ onClick={() =>
+ void navigate({ search: { agent: agentId }, to: "/channel/new" })
+ }
+ >
+ Start new channel
+ </Button>
+ <Button
+ className="w-full text-sm!"
+ onClick={() => setManaging(true)}
+ variant="outline"
+ >
+ Manage coworker
+ </Button>
+ </div>
- {isConfirmingDelete ? (
- <div className="flex flex-col gap-2">
- <p className="text-sm">
- Delete <span className="font-medium">{profile.name}</span>?
- This cannot be undone.
- </p>
- {/* Cancel remains closest to the original Delete button position. */}
- <Button
- className="w-full text-sm!"
- onClick={() => setConfirmingDeleteId(null)}
- variant="outline"
- >
- Cancel
- </Button>
- <Button
- className="w-full text-sm!"
- disabled={deleteAgent.isPending}
- onClick={async () => {
- await deleteAgent.mutateAsync(agentId);
- await navigate({ search: {}, to: "/agents" });
- }}
- variant="destructive"
- >
- {deleteAgent.isPending ? "Deleting…" : "Delete"}
- </Button>
- </div>
- ) : (
- <Button
- className="w-full text-sm!"
- onClick={() => setConfirmingDeleteId(agentId)}
- variant="destructive"
- >
- Delete
- </Button>
- )}
- </>
- ) : null}
- </div>
- )}
+ <AgentDialog
+ agentId={agentId}
+ onClose={() => setManaging(false)}
+ open={managing}
+ />
</div>
);
}
diff --git a/app/src/components/agents/create-agent-dialog.tsx b/app/src/components/agents/create-agent-dialog.tsx
new file mode 100644
index 00000000..eecc9367
--- /dev/null
+++ b/app/src/components/agents/create-agent-dialog.tsx
@@ -0,0 +1,614 @@
+import { useMutation, useQuery } from "@tanstack/react-query";
+import { AnimatePresence, MotionConfig, motion } from "motion/react";
+import { useState } from "react";
+import useMeasure from "react-use-measure";
+import { Button } from "@/components/ui/button";
+import {
+ Dialog,
+ DialogBody,
+ DialogContent,
+ DialogTitle,
+} from "@/components/ui/dialog";
+import {
+ Field,
+ FieldError,
+ FieldGroup,
+ FieldLabel,
+} from "@/components/ui/field";
+import { Input } from "@/components/ui/input";
+import {
+ Questionnaire,
+ QuestionnaireChoice,
+ QuestionnaireChoiceDescription,
+ QuestionnaireChoices,
+ QuestionnaireDescription,
+ QuestionnaireItem,
+ QuestionnaireTitle,
+} from "@/components/ui/questionnaire";
+import { Textarea } from "@/components/ui/textarea";
+import {
+ type AgentFormValues,
+ agentFormSchema,
+ agentInputFrom,
+ emptyAgentForm,
+} from "@/lib/agents/form";
+import { createAgentMutationOptions } from "@/lib/agents/mutations";
+import {
+ agentCapabilitiesQueryOptions,
+ type ConnectionVerdict,
+ testAgentConnection,
+} from "@/lib/agents/queries";
+import { queryClient } from "@/query-client";
+
+/**
+ * Creating a coworker, one question at a time.
+ *
+ * A wizard rather than a form, because the answers are three different kinds of decision: who this
+ * coworker is, who may see it, and where it runs. The last one is the fork — a built-in coworker
+ * needs nothing more, a managed one needs an endpoint — and a flat form showing endpoint fields to
+ * everybody made the common case read like the hard one.
+ */
+export function CreateAgentDialog({
+ open,
+ onClose,
+ onCreated,
+}: {
+ open: boolean;
+ onClose: () => void;
+ /** The new coworker's id, so the caller can open its dialog on it. */
+ onCreated: (agentId: string) => void;
+}) {
+ return (
+ <Dialog onOpenChange={(next) => !next && onClose()} open={open}>
+ <DialogContent>
+ {/* All wizard state lives below DialogContent, whose portal unmounts on close: dismissing
+ the dialog mid-way discards the half-answered steps rather than pickling them. */}
+ <CreateAgentWizard onClose={onClose} onCreated={onCreated} />
+ </DialogContent>
+ </Dialog>
+ );
+}
+
+/** The steps, in the order they are asked. The name is the questionnaire item's name. */
+const STEPS = ["identity", "visibility", "kind"] as const;
+type StepName = (typeof STEPS)[number];
+
+/** The two ways a coworker can be seen. */
+const VISIBILITY_OPTIONS: Array<{
+ value: AgentFormValues["visibility"];
+ title: string;
+ description: string;
+}> = [
+ {
+ value: "private",
+ title: "Private",
+ description: "Only you can see it and start channels with it.",
+ },
+ {
+ value: "public",
+ title: "Public",
+ description: "Everyone in the deployment can find and use it.",
+ },
+];
+
+/**
+ * Where the coworker runs. Not a stored field: the server knows only whether an endpoint was
+ * given, so "built-in" is the empty endpoint and this choice exists to make that fork explicit.
+ */
+type AgentKind = "builtin" | "managed";
+
+const KIND_OPTIONS: Array<{
+ value: AgentKind;
+ title: string;
+ description: string;
+}> = [
+ {
+ value: "builtin",
+ title: "Built-in",
+ description:
+ "Runs on this deployment's own Bot. Nothing to host or connect — it is ready the moment it is created.",
+ },
+ {
+ value: "managed",
+ title: "Managed",
+ description:
+ "Runs on an agent you host, spoken to over AG-UI. This server dials your endpoint on every run.",
+ },
+];
+
+/** The first step's slice of the form contract, so its errors match the server's limits. */
+const identitySchema = agentFormSchema.pick({
+ name: true,
+ title: true,
+ roleDescription: true,
+});
+
+type IdentityField = keyof typeof identitySchema.shape;
+
+/** First message per field, or nothing when the step parses. */
+function identityIssues(
+ values: AgentFormValues,
+): Partial<Record<IdentityField, string>> {
+ const parsed = identitySchema.safeParse(values);
+ if (parsed.success) return {};
+ const issues: Partial<Record<IdentityField, string>> = {};
+ for (const issue of parsed.error.issues) {
+ const field = issue.path[0] as IdentityField | undefined;
+ if (field && !issues[field]) issues[field] = issue.message;
+ }
+ return issues;
+}
+
+/** A pane arrives from the side the journey is moving toward, and leaves out the other. */
+const variants = {
+ initial: (direction: number) => ({ x: `${110 * direction}%`, opacity: 0 }),
+ active: { x: "0%", opacity: 1 },
+ exit: (direction: number) => ({ x: `${-110 * direction}%`, opacity: 0 }),
+};
+
+function CreateAgentWizard({
+ onClose,
+ onCreated,
+}: {
+ onClose: () => void;
+ onCreated: (agentId: string) => void;
+}) {
+ const createAgent = useMutation(createAgentMutationOptions(queryClient));
+ /*
+ * Whether "built-in" is a coworker this deployment can actually make. Assumed true while the
+ * answer is loading, so the common deployment never sees the card flash from disabled to
+ * enabled; the server refuses the create either way, so an optimistic card risks nothing.
+ */
+ const { data: capabilities } = useQuery(agentCapabilitiesQueryOptions());
+ const builtInAvailable = capabilities?.builtInAvailable ?? true;
+
+ const [step, setStep] = useState(0);
+ const [direction, setDirection] = useState(1);
+ /** Whether this step's Continue was pressed, which is when its errors become worth showing. */
+ const [tried, setTried] = useState(false);
+ const [values, setValues] = useState<AgentFormValues>(emptyAgentForm);
+ /** Deliberately unanswered to start with: revealing endpoint fields is the point of asking. */
+ const [kind, setKind] = useState<AgentKind | null>(null);
+
+ const [connection, setConnection] = useState<ConnectionVerdict | null>(null);
+ const [testing, setTesting] = useState(false);
+ const [ref, bounds] = useMeasure();
+
+ const last = step === STEPS.length - 1;
+ const set = <K extends keyof AgentFormValues>(
+ key: K,
+ value: AgentFormValues[K],
+ ) => setValues((current) => ({ ...current, [key]: value }));
+
+ /** Test endpoint reachability from the server, which is what runs will use. */
+ const testConnection = async () => {
+ setTesting(true);
+ setConnection(null);
+ try {
+ setConnection(
+ await testAgentConnection(values.endpoint, values.authValue),
+ );
+ } finally {
+ setTesting(false);
+ }
+ };
+
+ const identityErrors = tried ? identityIssues(values) : {};
+ const endpointError = !tried
+ ? undefined
+ : kind === "managed" && values.endpoint.trim() === ""
+ ? "An endpoint is required for a managed coworker."
+ : agentFormSchema.shape.endpoint.safeParse(values.endpoint).error
+ ?.issues[0]?.message;
+
+ const stepValid = (): boolean => {
+ if (STEPS[step] === "identity") {
+ return identitySchema.safeParse(values).success;
+ }
+ if (STEPS[step] === "kind") {
+ if (kind === null) return false;
+ if (kind === "builtin") return true;
+ return (
+ values.endpoint.trim() !== "" &&
+ agentFormSchema.shape.endpoint.safeParse(values.endpoint).success
+ );
+ }
+ // Visibility always holds an answer; the radio starts on private.
+ return true;
+ };
+
+ const go = (to: number) => {
+ setDirection(to > step ? 1 : -1);
+ setTried(false);
+ setStep(to);
+ };
+
+ /**
+ * Every way forward lands here — the Continue button, Enter in a field, Enter on a choice — as
+ * the questionnaire form's submit. Backwards never validates; half answers are fine to leave.
+ */
+ const advance = async () => {
+ if (!stepValid()) {
+ setTried(true);
+ return;
+ }
+ if (!last) {
+ go(step + 1);
+ return;
+ }
+ const agent = await createAgent.mutateAsync(agentInputFrom(values));
+ onCreated(agent.id);
+ };
+
+ return (
+ <>
+ {/* Read aloud, never shown: each step carries its own heading, and a dialog-level title
+ above them made two heading sizes compete. The popup still needs an accessible name. */}
+ <DialogTitle className="sr-only">New coworker</DialogTitle>
+ <DialogBody className="overflow-y-auto">
+ <Questionnaire
+ item={STEPS[step]}
+ noValidate
+ /*
+ * Enter means Continue, handled here rather than through the form's submit. The
+ * questionnaire's own submit path refuses any item it does not consider answered, and it
+ * cannot see these fields: the identity inputs are this dialog's own, not registered
+ * answers. Running first and preventing default also keeps the primitive's Enter
+ * handling out of the way; a textarea keeps Enter for its line breaks.
+ */
+ onKeyDown={(event) => {
+ if (
+ event.key === "Enter" &&
+ !event.shiftKey &&
+ event.target instanceof HTMLInputElement
+ ) {
+ event.preventDefault();
+ void advance();
+ }
+ }}
+ onSubmit={(event) => event.preventDefault()}
+ >
+ {/* A plain element rather than QuestionnaireProgress: only the active step is mounted,
+ so the primitive would count one question and announce the wrong total. */}
+ <p className="text-xs font-medium text-muted-foreground tabular-nums">
+ Step {step + 1} of {STEPS.length}
+ </p>
+ <MotionConfig
+ transition={{ duration: 0.5, type: "spring", bounce: 0 }}
+ >
+ {/* The frame follows each pane's height, so the buttons glide instead of jumping.
+ `relative` is load-bearing: popLayout positions the exiting pane absolutely, and an
+ absolute element is clipped by overflow-hidden only on an ancestor that positions
+ it. Without this its containing block is the dialog popup, and the old pane slides
+ across the whole dialog instead of out of this frame. */}
+ <motion.div
+ animate={{ height: bounds.height > 0 ? bounds.height : "auto" }}
+ className="relative overflow-hidden"
+ >
+ <div ref={ref}>
+ <AnimatePresence
+ custom={direction}
+ initial={false}
+ mode="popLayout"
+ >
+ <motion.div
+ animate="active"
+ className="pt-4"
+ custom={direction}
+ exit="exit"
+ initial="initial"
+ key={STEPS[step]}
+ variants={variants}
+ >
+ {STEPS[step] === "identity" ? (
+ <IdentityStep
+ errors={identityErrors}
+ set={set}
+ values={values}
+ />
+ ) : STEPS[step] === "visibility" ? (
+ <VisibilityStep set={set} values={values} />
+ ) : (
+ <KindStep
+ builtInAvailable={builtInAvailable}
+ endpointError={endpointError}
+ kind={kind}
+ onKind={(next) => {
+ setKind(next);
+ if (next === "builtin") {
+ // A built-in coworker has no endpoint; whatever was typed on the way
+ // past must not ride along into the create.
+ set("endpoint", "");
+ set("authValue", "");
+ setConnection(null);
+ }
+ }}
+ onTest={() => void testConnection()}
+ connection={connection}
+ set={set}
+ showKindError={tried && kind === null}
+ testing={testing}
+ values={values}
+ />
+ )}
+ </motion.div>
+ </AnimatePresence>
+ </div>
+ </motion.div>
+ </MotionConfig>
+
+ {createAgent.error ? (
+ <p className="mt-4 text-sm text-destructive" role="alert">
+ {createAgent.error.message}
+ </p>
+ ) : null}
+
+ <div className="mt-6 flex justify-between gap-2">
+ <Button
+ onClick={step === 0 ? onClose : () => go(step - 1)}
+ type="button"
+ variant="outline"
+ >
+ {step === 0 ? "Cancel" : "Back"}
+ </Button>
+ <Button
+ disabled={createAgent.isPending}
+ onClick={() => void advance()}
+ type="button"
+ >
+ {last
+ ? createAgent.isPending
+ ? "Creating…"
+ : "Create coworker"
+ : "Continue"}
+ </Button>
+ </div>
+ </Questionnaire>
+ </DialogBody>
+ </>
+ );
+}
+
+/**
+ * `hidden={false}` and `inert={false}` on every item, against the questionnaire's own hiding.
+ *
+ * The primitive blanks any item that is not the active one, which is right for its stacked layout
+ * and wrong here: only the active step is mounted, except for the instant an old pane is sliding
+ * out under AnimatePresence — exactly when the primitive would blank it mid-slide. The item's
+ * visibility is the animation's job in this dialog, never the questionnaire's.
+ */
+function StepItem({
+ name,
+ children,
+}: {
+ name: StepName;
+ children: React.ReactNode;
+}) {
+ return (
+ <QuestionnaireItem hidden={false} inert={false} name={name}>
+ {children}
+ </QuestionnaireItem>
+ );
+}
+
+function IdentityStep({
+ values,
+ errors,
+ set,
+}: {
+ values: AgentFormValues;
+ errors: Partial<Record<IdentityField, string>>;
+ set: <K extends keyof AgentFormValues>(
+ key: K,
+ value: AgentFormValues[K],
+ ) => void;
+}) {
+ return (
+ <StepItem name="identity">
+ <QuestionnaireTitle>Who is this coworker?</QuestionnaireTitle>
+ <QuestionnaireDescription>
+ The role you write here applies in every channel this coworker works in.
+ </QuestionnaireDescription>
+ <FieldGroup>
+ <Field data-invalid={errors.name ? true : undefined}>
+ <FieldLabel htmlFor="create-agent-name">Name</FieldLabel>
+ <Input
+ aria-invalid={errors.name ? true : undefined}
+ id="create-agent-name"
+ onChange={(event) => set("name", event.target.value)}
+ placeholder="Expense Manager"
+ value={values.name}
+ />
+ {errors.name ? (
+ <FieldError errors={[{ message: errors.name }]} />
+ ) : null}
+ </Field>
+ <Field data-invalid={errors.title ? true : undefined}>
+ <FieldLabel htmlFor="create-agent-title">Title</FieldLabel>
+ <Input
+ aria-invalid={errors.title ? true : undefined}
+ id="create-agent-title"
+ onChange={(event) => set("title", event.target.value)}
+ placeholder="Finance Operations"
+ value={values.title}
+ />
+ {errors.title ? (
+ <FieldError errors={[{ message: errors.title }]} />
+ ) : null}
+ </Field>
+ <Field data-invalid={errors.roleDescription ? true : undefined}>
+ <FieldLabel htmlFor="create-agent-role">Role</FieldLabel>
+ <Textarea
+ aria-invalid={errors.roleDescription ? true : undefined}
+ id="create-agent-role"
+ onChange={(event) => set("roleDescription", event.target.value)}
+ placeholder="Review receipts, categorize expenses, and prepare reimbursement reports."
+ rows={4}
+ value={values.roleDescription}
+ />
+ {errors.roleDescription ? (
+ <FieldError errors={[{ message: errors.roleDescription }]} />
+ ) : null}
+ </Field>
+ </FieldGroup>
+ </StepItem>
+ );
+}
+
+function VisibilityStep({
+ values,
+ set,
+}: {
+ values: AgentFormValues;
+ set: <K extends keyof AgentFormValues>(
+ key: K,
+ value: AgentFormValues[K],
+ ) => void;
+}) {
+ return (
+ <StepItem name="visibility">
+ <QuestionnaireTitle>Who can see it?</QuestionnaireTitle>
+ <QuestionnaireChoices>
+ {VISIBILITY_OPTIONS.map((option) => (
+ <QuestionnaireChoice
+ checked={values.visibility === option.value}
+ key={option.value}
+ onChange={() => set("visibility", option.value)}
+ value={option.value}
+ >
+ <span className="font-medium">{option.title}</span>
+ <QuestionnaireChoiceDescription>
+ {option.description}
+ </QuestionnaireChoiceDescription>
+ </QuestionnaireChoice>
+ ))}
+ </QuestionnaireChoices>
+ </StepItem>
+ );
+}
+
+function KindStep({
+ builtInAvailable,
+ kind,
+ onKind,
+ showKindError,
+ values,
+ set,
+ endpointError,
+ connection,
+ testing,
+ onTest,
+}: {
+ /** Whether this deployment has a Bot of its own for a coworker to run on. */
+ builtInAvailable: boolean;
+ kind: AgentKind | null;
+ onKind: (kind: AgentKind) => void;
+ showKindError: boolean;
+ values: AgentFormValues;
+ set: <K extends keyof AgentFormValues>(
+ key: K,
+ value: AgentFormValues[K],
+ ) => void;
+ endpointError?: string;
+ connection: ConnectionVerdict | null;
+ testing: boolean;
+ onTest: () => void;
+}) {
+ return (
+ <StepItem name="kind">
+ <QuestionnaireTitle>Where does it run?</QuestionnaireTitle>
+ <QuestionnaireChoices>
+ {KIND_OPTIONS.map((option) => {
+ /*
+ * Shown but not offerable, rather than hidden: a deployment with no managed Bot cannot
+ * back a built-in coworker, and the create would be refused. The card staying visible is
+ * what tells the person the kind exists and why it is not theirs to pick.
+ */
+ const unavailable = option.value === "builtin" && !builtInAvailable;
+ return (
+ <QuestionnaireChoice
+ checked={kind === option.value}
+ disabled={unavailable}
+ key={option.value}
+ onChange={() => onKind(option.value)}
+ value={option.value}
+ >
+ <span className="font-medium">{option.title}</span>
+ <QuestionnaireChoiceDescription>
+ {unavailable
+ ? "Not available here: this deployment has no Bot of its own for a coworker to run on."
+ : option.description}
+ </QuestionnaireChoiceDescription>
+ </QuestionnaireChoice>
+ );
+ })}
+ </QuestionnaireChoices>
+ {showKindError ? (
+ <p className="text-sm text-destructive" role="alert">
+ Choose where this coworker runs.
+ </p>
+ ) : null}
+ {kind === "managed" ? (
+ <FieldGroup>
+ <Field data-invalid={endpointError ? true : undefined}>
+ <FieldLabel htmlFor="create-agent-endpoint">
+ Agent endpoint
+ </FieldLabel>
+ <div className="flex gap-2">
+ <Input
+ aria-invalid={endpointError ? true : undefined}
+ id="create-agent-endpoint"
+ onChange={(event) => set("endpoint", event.target.value)}
+ placeholder="https://your-agent.example.com/ag-ui"
+ value={values.endpoint}
+ />
+ <Button
+ disabled={!values.endpoint || testing}
+ onClick={onTest}
+ type="button"
+ variant="outline"
+ >
+ {testing ? "Testing…" : "Test"}
+ </Button>
+ </div>
+ {endpointError ? (
+ <FieldError errors={[{ message: endpointError }]} />
+ ) : null}
+ {connection ? (
+ <p
+ className={`text-sm ${connection.ok ? "text-muted-foreground" : "text-destructive"}`}
+ role="status"
+ >
+ {connection.ok
+ ? `It answered: ${connection.events.join(", ")}`
+ : connection.reason}
+ </p>
+ ) : (
+ <p className="text-muted-foreground text-sm">
+ Anything that speaks AG-UI works. This server dials your agent,
+ so an agent on your own machine has to be reachable from here.
+ </p>
+ )}
+ </Field>
+ <Field>
+ <FieldLabel htmlFor="create-agent-key">
+ Key for that agent (optional)
+ </FieldLabel>
+ <Input
+ autoComplete="off"
+ id="create-agent-key"
+ onChange={(event) => set("authValue", event.target.value)}
+ placeholder="Bearer …"
+ type="password"
+ value={values.authValue}
+ />
+ <p className="text-muted-foreground text-sm">
+ Sent as an <code>Authorization</code> header on every run, and
+ kept in the credential vault.
+ </p>
+ </Field>
+ </FieldGroup>
+ ) : null}
+ </StepItem>
+ );
+}
diff --git a/app/src/components/agents/handoff-panel.tsx b/app/src/components/agents/handoff-panel.tsx
index bc299f93..2c7a7a58 100644
--- a/app/src/components/agents/handoff-panel.tsx
+++ b/app/src/components/agents/handoff-panel.tsx
@@ -1,5 +1,19 @@
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { AbstractAvatar } from "@/components/agents/abstract-avatar";
+import {
+ Empty,
+ EmptyDescription,
+ EmptyHeader,
+ EmptyTitle,
+} from "@/components/ui/empty";
+import {
+ Item,
+ ItemActions,
+ ItemContent,
+ ItemDescription,
+ ItemMedia,
+ ItemTitle,
+} from "@/components/ui/item";
import { Switch } from "@/components/ui/switch";
import { setHandoffGrantMutationOptions } from "@/lib/agents/mutations";
import {
@@ -16,6 +30,9 @@ import {
*
* DIRECTIONAL, and said so on the screen, because the pair is the one thing about this that is easy
* to get backwards: this is who this Bot may ask, not who may ask it.
+ *
+ * One Item per candidate, with a Switch: the grant is one boolean that takes effect when switched,
+ * which is exactly the row kind a Switch means everywhere else in this app.
*/
export function HandoffPanel({ agentId }: { agentId: string }) {
const queryClient = useQueryClient();
@@ -24,7 +41,7 @@ export function HandoffPanel({ agentId }: { agentId: string }) {
const setGrant = useMutation(setHandoffGrantMutationOptions(queryClient));
if (handoff.isPending || !handoff.data) return null;
- const { enabled, canGrant, reachable } = handoff.data;
+ const { enabled, canGrant, reachable, grantable } = handoff.data;
/*
* A Bot may not be granted itself, and the server refuses it, so it is not offered here either.
@@ -33,59 +50,109 @@ export function HandoffPanel({ agentId }: { agentId: string }) {
const others = (agents.data ?? []).filter(
(candidate) => candidate.id !== agentId,
);
+ const granted = others.filter((candidate) =>
+ reachable.includes(candidate.id),
+ ).length;
+ /*
+ * On a Bot that cannot be a grantee only the leftovers are shown: a stale grant may still be
+ * revoked — taking away is always allowed — but offering switches that can only bounce off the
+ * server's refusal is the thing the explanation item above replaces.
+ */
+ const candidates = grantable
+ ? others
+ : others.filter((candidate) => reachable.includes(candidate.id));
// Nothing to say to somebody who cannot change it and has nothing to read.
if (!canGrant && reachable.length === 0) return null;
return (
- <section className="mt-6 grid gap-2">
- <h2 className="font-medium text-muted-foreground text-xs uppercase tracking-wide">
- Bots it may ask
- </h2>
+ <section className="grid gap-2">
+ <header className="flex items-baseline justify-between gap-2">
+ <h2 className="font-medium text-muted-foreground text-xs uppercase tracking-wide">
+ Bots it may ask
+ </h2>
+ {/* The current answer at a glance, so the list below is detail rather than homework. */}
+ {grantable && others.length > 0 ? (
+ <span className="text-muted-foreground text-xs tabular-nums">
+ {granted} of {others.length}
+ </span>
+ ) : null}
+ </header>
<p className="text-muted-foreground text-sm">
- {enabled
- ? "Work this Bot cannot do itself, it may hand to one of these. The Bot it asks answers in its own conversation, as itself."
- : "Handing work between Bots is switched off for this deployment, so none of these takes effect until it is switched back on."}
+ Who this Bot may ask, not who may ask it. What the asked Bot says comes
+ back into the conversation that asked, relayed and attributed.
</p>
+ {enabled ? null : (
+ <Item variant="muted">
+ <ItemContent>
+ <ItemTitle>Switched off for this deployment</ItemTitle>
+ {/*
+ * Unclamped: `ItemDescription` clips to two lines, which is right for a roster row
+ * whose description is a subtitle and wrong for an item that exists to explain. The
+ * sentence that gets cut is the one saying what to do about it.
+ */}
+ <ItemDescription className="line-clamp-none">
+ These grants are kept but none takes effect until handing work
+ between Bots is switched back on.
+ </ItemDescription>
+ </ItemContent>
+ </Item>
+ )}
+
+ {grantable ? null : (
+ <Item variant="muted">
+ <ItemContent>
+ <ItemTitle>This coworker cannot hand work on</ItemTitle>
+ {/* Unclamped for the same reason as above: three lines, and the third is the useful one. */}
+ <ItemDescription className="line-clamp-none">
+ Handing work on is a tool that runs inside this deployment's own
+ loop, and this coworker runs as its own agent — so there is
+ nothing to grant it. It can still be asked by Bots that can.
+ </ItemDescription>
+ </ItemContent>
+ </Item>
+ )}
+
{setGrant.error ? (
<p className="text-destructive text-sm" role="alert">
{setGrant.error.message}
</p>
) : null}
- {others.length === 0 ? (
- <p className="text-muted-foreground text-sm">
- There is no other Bot here to hand work to.
- </p>
- ) : (
- <ul className="grid gap-1 rounded-lg border border-border bg-card p-1">
- {others.map((candidate) => {
- const held = reachable.includes(candidate.id);
- return (
- <li
- className="flex items-center justify-between gap-3 rounded-md px-2 py-1.5"
- key={candidate.id}
- >
- <span className="flex min-w-0 items-center gap-2">
- <AbstractAvatar
- name={candidate.name}
- seed={candidate.avatarSeed}
- size={24}
- />
- <span className="min-w-0">
- <span className="block truncate text-sm">
- {candidate.name}
- </span>
- <span className="block truncate text-muted-foreground text-xs">
- {candidate.title}
- </span>
- </span>
- </span>
+ {grantable && others.length === 0 ? (
+ <Empty className="h-[180px] border border-dashed">
+ <EmptyHeader>
+ <EmptyTitle className="text-muted-foreground">
+ No other Bot here yet
+ </EmptyTitle>
+ <EmptyDescription>
+ When this deployment has more Bots, this is where this one is
+ allowed to ask them.
+ </EmptyDescription>
+ </EmptyHeader>
+ </Empty>
+ ) : null}
+ {candidates.length > 0 ? (
+ <div className="flex flex-col gap-2">
+ {candidates.map((candidate) => (
+ <Item key={candidate.id} size="sm" variant="muted">
+ <ItemMedia>
+ <AbstractAvatar
+ name={candidate.name}
+ seed={candidate.avatarSeed}
+ size={28}
+ />
+ </ItemMedia>
+ <ItemContent>
+ <ItemTitle>{candidate.name}</ItemTitle>
+ <ItemDescription>{candidate.title}</ItemDescription>
+ </ItemContent>
+ <ItemActions>
<Switch
aria-label={`Let this Bot ask ${candidate.name}`}
- checked={held}
+ checked={reachable.includes(candidate.id)}
disabled={!canGrant || setGrant.isPending}
onCheckedChange={(next: boolean) =>
setGrant.mutate({
@@ -95,11 +162,11 @@ export function HandoffPanel({ agentId }: { agentId: string }) {
})
}
/>
- </li>
- );
- })}
- </ul>
- )}
+ </ItemActions>
+ </Item>
+ ))}
+ </div>
+ ) : null}
{canGrant ? null : (
<p className="text-muted-foreground text-xs">
diff --git a/app/src/components/agents/new-agent.tsx b/app/src/components/agents/new-agent.tsx
deleted file mode 100644
index c99bb222..00000000
--- a/app/src/components/agents/new-agent.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import { useMutation, useQueryClient } from "@tanstack/react-query";
-import { useNavigate } from "@tanstack/react-router";
-import { AgentFields } from "@/components/agents/agent-fields";
-import { agentInputFrom, emptyAgentForm } from "@/lib/agents/form";
-import { createAgentMutationOptions } from "@/lib/agents/mutations";
-
-export function NewAgent() {
- const queryClient = useQueryClient();
- const navigate = useNavigate();
- const createAgent = useMutation(createAgentMutationOptions(queryClient));
-
- return (
- <div className="mx-auto flex w-full max-w-xl flex-col gap-6 p-8">
- <header>
- <h1 className="text-2xl font-semibold">New coworker</h1>
- <p className="mt-1 text-sm text-muted-foreground">
- The role you write here applies in every channel this coworker works
- in.
- </p>
- </header>
-
- <AgentFields
- defaultValues={emptyAgentForm}
- error={createAgent.error}
- onSubmit={async (values) => {
- // The panel swaps from the form to the new coworker's profile, and the roster behind it
- // picks up the new card: the next thing to do is start a channel with it.
- const agent = await createAgent.mutateAsync(agentInputFrom(values));
- await navigate({ search: { agent: agent.id }, to: "/agents" });
- }}
- submitLabel="Create coworker"
- />
- </div>
- );
-}
diff --git a/app/src/components/app-sidebar/app-sidebar.tsx b/app/src/components/app-sidebar/app-sidebar.tsx
index 94051101..d70023f2 100644
--- a/app/src/components/app-sidebar/app-sidebar.tsx
+++ b/app/src/components/app-sidebar/app-sidebar.tsx
@@ -1,7 +1,6 @@
import {
IconBolt,
IconBox,
- IconClock,
IconLogout,
IconPlus,
IconSearch,
@@ -363,26 +362,9 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
<span className="text-sm trackint-tight">Agents</span>
</SidebarMenuButton>
</SidebarMenuItem>
- <SidebarMenuItem>
- {/* Beside Skills and Agents rather than inside Admin: a routine is something anybody has. */}
- <SidebarMenuButton
- className="hover:bg-foreground/5 h-10"
- render={(props) => (
- <Link
- {...props}
- to="/routines"
- activeProps={{
- className: "bg-foreground/5",
- }}
- />
- )}
- >
- <div className="size-[28px] flex items-center justify-center">
- <IconClock />
- </div>
- <span className="text-sm trackint-tight">Routines</span>
- </SidebarMenuButton>
- </SidebarMenuItem>
+ {/* Routines live on each coworker's own dialog now, not as a nav destination: the
+ question "what does this Bot do on a schedule" is asked while looking at the Bot.
+ The /routines route still answers a direct link. */}
<SidebarMenuItem>
<DropdownMenu>
<DropdownMenuTrigger
diff --git a/app/src/components/routines/routines-list.tsx b/app/src/components/routines/routines-list.tsx
index 4697d746..4f50be0b 100644
--- a/app/src/components/routines/routines-list.tsx
+++ b/app/src/components/routines/routines-list.tsx
@@ -1,11 +1,8 @@
import { IconTrash } from "@tabler/icons-react";
import { useMutation, useQuery } from "@tanstack/react-query";
+import { Link } from "@tanstack/react-router";
import { useState } from "react";
-import {
- PageEmpty,
- PageRows,
- PageSection,
-} from "@/components/layout/page-shell";
+import { PageSection } from "@/components/layout/page-shell";
import { Button } from "@/components/ui/button";
import {
Dialog,
@@ -15,6 +12,12 @@ import {
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
+import {
+ Empty,
+ EmptyDescription,
+ EmptyHeader,
+ EmptyTitle,
+} from "@/components/ui/empty";
import {
Item,
ItemActions,
@@ -23,7 +26,6 @@ import {
ItemFooter,
ItemTitle,
} from "@/components/ui/item";
-import { Separator } from "@/components/ui/separator";
import { Switch } from "@/components/ui/switch";
import { relativeTime } from "@/lib/relative-time";
import {
@@ -34,6 +36,7 @@ import {
type RoutineRecord,
routinesQueryOptions,
} from "@/lib/routines/queries";
+import { cn } from "@/lib/utils";
import { queryClient } from "@/query-client";
/**
@@ -47,47 +50,106 @@ import { queryClient } from "@/query-client";
function lastRunLabel(lastRun: RoutineRecord["lastRun"]): {
text: string;
className: string;
+ /** The chip's dot, which carries the tone so the text can stay readable. */
+ dot: string;
} {
if (lastRun === null) {
- return { text: "Never run yet", className: "text-muted-foreground" };
+ return {
+ text: "Never run yet",
+ className: "text-muted-foreground",
+ dot: "bg-muted-foreground/40",
+ };
}
if (lastRun.status === null) {
- return { text: "Running…", className: "text-muted-foreground" };
+ return {
+ text: "Running…",
+ className: "text-muted-foreground",
+ dot: "animate-pulse bg-muted-foreground",
+ };
}
const when = lastRun.at ? relativeTime(lastRun.at) : "recently";
if (lastRun.status === "failed") {
- return { text: `Failed ${when}`, className: "text-destructive" };
+ return {
+ text: `Failed ${when}`,
+ className: "text-destructive",
+ dot: "bg-destructive",
+ };
}
if (lastRun.status === "skipped") {
return {
text: `Skipped ${when}`,
className: "text-amber-600 dark:text-amber-500",
+ dot: "bg-amber-500",
};
}
if (lastRun.status === "succeeded") {
- return { text: `Ran ${when}`, className: "text-muted-foreground" };
+ return {
+ text: `Ran ${when}`,
+ className: "text-muted-foreground",
+ dot: "bg-emerald-500",
+ };
}
// An outcome this DTO doesn't recognise degrades to a neutral label rather than an invented
// success — the contract typing (`RoutineRunOutcome | null`) makes a fourth outcome a build-time
// error, but this is the runtime fallback if that ever slips through.
- return { text: `Finished ${when}`, className: "text-muted-foreground" };
+ return {
+ text: `Finished ${when}`,
+ className: "text-muted-foreground",
+ dot: "bg-muted-foreground/40",
+ };
}
/**
- * The one list the Routines page shows: every standing instruction the signed-in person owns, a
- * switch to stop one taking effect, and a delete that ends it for good.
+ * One fact about a routine, worn as a small pill so the footer reads as a row of states rather
+ * than a sentence. On the muted item the pill's own background is what keeps it legible.
*/
-export function RoutinesList() {
+function Chip({
+ className,
+ children,
+}: {
+ className?: string;
+ children: React.ReactNode;
+}) {
+ return (
+ <span
+ className={cn(
+ "inline-flex items-center gap-1.5 rounded-full border border-border bg-background/60 px-2 py-0.5 text-xs",
+ className,
+ )}
+ >
+ {children}
+ </span>
+ );
+}
+
+/**
+ * The signed-in person's standing instructions: a switch to stop one taking effect, and a delete
+ * that ends it for good.
+ *
+ * Scoped by `agentId` on a Bot's own dialog, unscoped on the Routines page. One query either way —
+ * the list is owner-scoped and small, so the scope is a filter here rather than a second endpoint.
+ */
+export function RoutinesList({
+ agentId,
+ embedded = false,
+}: {
+ /** Show only the routines this Bot carries out. Absent shows all of the person's. */
+ agentId?: string;
+ /** Inside a dialog, where the page section's own top margin is somebody else's spacing. */
+ embedded?: boolean;
+} = {}) {
const routines = useQuery(routinesQueryOptions());
const setEnabled = useMutation(setRoutineEnabledMutationOptions(queryClient));
const deleteRoutine = useMutation(deleteRoutineMutationOptions(queryClient));
/** The routine a delete is being confirmed for, or null. Its own dialog rather than one per row. */
const [confirmingId, setConfirmingId] = useState<string | null>(null);
- const rows = routines.data ?? [];
+ const rows = (routines.data ?? []).filter(
+ (row) => agentId === undefined || row.agentId === agentId,
+ );
const confirming = rows.find((row) => row.id === confirmingId) ?? null;
return (
- <PageSection>
+ <PageSection className={embedded ? "mt-0" : undefined}>
{setEnabled.error ? (
<p className="text-destructive text-sm" role="alert">
{setEnabled.error.message}
@@ -100,93 +162,122 @@ export function RoutinesList() {
Your routines could not be loaded.
</p>
) : rows.length === 0 ? (
- <PageEmpty>
- Nothing scheduled. Ask a Bot — "every weekday at 9, …" — and it will
- appear here.
- </PageEmpty>
+ <Empty className="h-[180px] border border-dashed">
+ <EmptyHeader>
+ <EmptyTitle className="text-muted-foreground">
+ {agentId
+ ? "Nothing scheduled for this coworker"
+ : "Nothing scheduled"}
+ </EmptyTitle>
+ <EmptyDescription>
+ {agentId
+ ? 'Ask it in a channel — "every weekday at 9, …" — and it will appear here.'
+ : 'Ask a Bot — "every weekday at 9, …" — and it will appear here.'}
+ </EmptyDescription>
+ </EmptyHeader>
+ </Empty>
) : (
- <PageRows>
- {rows.map((routine, index) => {
- const { text: lastRunText, className: lastRunClassName } =
- lastRunLabel(routine.lastRun);
+ <div className="flex flex-col gap-2">
+ {rows.map((routine) => {
+ const lastRun = lastRunLabel(routine.lastRun);
return (
- <div key={routine.id}>
- <Item size="sm">
- <ItemContent>
- <ItemTitle>
- {routine.schedule}
- <span className="font-normal text-muted-foreground text-xs">
- {routine.timezone}
- </span>
- </ItemTitle>
- <ItemDescription className="line-clamp-3">
- {routine.instruction}
- </ItemDescription>
- {/* A set, so it wraps onto its own line rather than crowding the title. */}
- <ItemFooter>
- <div className="flex flex-wrap items-center gap-3 text-xs">
- <span
- className={
- routine.channel.gone
- ? "text-destructive"
- : "text-muted-foreground"
- }
+ <Item key={routine.id} variant="muted">
+ {/* Paused reads at a glance: the content dims, and a chip below says the word. */}
+ <ItemContent className={routine.enabled ? "" : "opacity-60"}>
+ <ItemTitle>
+ {routine.schedule}
+ <span className="font-normal text-muted-foreground text-xs">
+ {routine.timezone}
+ </span>
+ </ItemTitle>
+ <ItemDescription className="line-clamp-2">
+ {routine.instruction}
+ </ItemDescription>
+ {/* A set, so it wraps onto its own line rather than crowding the title. */}
+ <ItemFooter>
+ <div className="flex flex-wrap items-center gap-1.5">
+ {routine.channel.gone ? (
+ <Chip className="border-destructive/40 text-destructive">
+ This channel is gone
+ </Chip>
+ ) : (
+ // Where it posts is a place, so the chip goes there.
+ <Link
+ params={{ channelId: routine.channel.id }}
+ to="/channel/$channelId"
>
- {routine.channel.gone
- ? "This channel is gone"
- : (routine.channel.name ?? "Unnamed channel")}
- </span>
- <span className={lastRunClassName}>{lastRunText}</span>
- {/*
- * Enabled only: the store recomputes nextRunAt on cron/timezone change or
- * re-enable, so a disabled routine's stamp is frozen in the past — rendering
- * it unguarded would announce a stale "3 days ago" as the next run.
- */}
- {routine.enabled ? (
- <span className="text-muted-foreground">
- Next {relativeTime(routine.nextRunAt)}
- </span>
- ) : null}
- </div>
- </ItemFooter>
- </ItemContent>
- <ItemActions>
- {/*
- * Binary and immediate: it takes effect when switched, there is no save.
- * Disabled only while its own write is in flight, so switching one routine
- * does not freeze the rest of the list — the same idiom the per-tool plugins
- * page uses for its per-Bot grant switches.
- */}
- <Switch
- aria-label={`Enable the routine scheduled ${routine.schedule}`}
- checked={routine.enabled}
- disabled={
- setEnabled.isPending &&
- setEnabled.variables?.id === routine.id
- }
- onCheckedChange={(next) =>
- setEnabled.mutate({ id: routine.id, enabled: next })
- }
- />
- <Button
- aria-label={`Delete the routine scheduled ${routine.schedule}`}
- onClick={() => {
- deleteRoutine.reset();
- setConfirmingId(routine.id);
- }}
- size="icon-sm"
- type="button"
- variant="ghost"
- >
- <IconTrash />
- </Button>
- </ItemActions>
- </Item>
- {index !== rows.length - 1 && <Separator />}
- </div>
+ <Chip className="text-muted-foreground transition-colors hover:text-foreground">
+ {routine.channel.name ?? "Unnamed channel"}
+ </Chip>
+ </Link>
+ )}
+ <Chip className={lastRun.className}>
+ <span
+ className={cn("size-1.5 rounded-full", lastRun.dot)}
+ />
+ {lastRun.text}
+ </Chip>
+ {/*
+ * Enabled only: the store recomputes nextRunAt on cron/timezone change or
+ * re-enable, so a disabled routine's stamp is frozen in the past — rendering
+ * it unguarded would announce a stale "3 days ago" as the next run. Paused
+ * takes its place, so the switch's state has a word as well as a position.
+ */}
+ {!routine.enabled ? (
+ <Chip className="text-muted-foreground">Paused</Chip>
+ ) : new Date(routine.nextRunAt).getTime() <=
+ Date.now() ? (
+ /*
+ * A stamp in the past is a firing the sweep has not picked up, and "Next 5
+ * hours ago" is nonsense. Said as what it is: due, and visibly waiting.
+ */
+ <Chip className="text-amber-600 dark:text-amber-500">
+ <span className="size-1.5 animate-pulse rounded-full bg-amber-500" />
+ Due
+ </Chip>
+ ) : (
+ <Chip className="text-muted-foreground">
+ Next {relativeTime(routine.nextRunAt)}
+ </Chip>
+ )}
+ </div>
+ </ItemFooter>
+ </ItemContent>
+ <ItemActions>
+ {/*
+ * Binary and immediate: it takes effect when switched, there is no save.
+ * Disabled only while its own write is in flight, so switching one routine
+ * does not freeze the rest of the list — the same idiom the per-tool plugins
+ * page uses for its per-Bot grant switches.
+ */}
+ <Switch
+ aria-label={`Enable the routine scheduled ${routine.schedule}`}
+ checked={routine.enabled}
+ disabled={
+ setEnabled.isPending &&
+ setEnabled.variables?.id === routine.id
+ }
+ onCheckedChange={(next) =>
+ setEnabled.mutate({ id: routine.id, enabled: next })
+ }
+ />
+ <Button
+ aria-label={`Delete the routine scheduled ${routine.schedule}`}
+ onClick={() => {
+ deleteRoutine.reset();
+ setConfirmingId(routine.id);
+ }}
+ size="icon-sm"
+ type="button"
+ variant="ghost"
+ >
+ <IconTrash />
+ </Button>
+ </ItemActions>
+ </Item>
);
})}
- </PageRows>
+ </div>
)}
{/*
@@ -201,7 +292,9 @@ export function RoutinesList() {
}}
open={confirming !== null}
>
- <DialogContent>
+ {/* The heavier backdrop, forced: opened from a Bot's dialog this stacks over it, and Base
+ UI would otherwise render a nested dialog with no backdrop at all. */}
+ <DialogContent overlayClassName="bg-black/20 supports-backdrop-filter:backdrop-blur-sm">
<DialogHeader>
<DialogTitle>Delete "{confirming?.schedule}"?</DialogTitle>
<DialogDescription>
diff --git a/app/src/components/ui/dialog.tsx b/app/src/components/ui/dialog.tsx
index 08880c94..bd5f7879 100644
--- a/app/src/components/ui/dialog.tsx
+++ b/app/src/components/ui/dialog.tsx
@@ -47,13 +47,27 @@ function DialogOverlay({ className, ...props }: DialogPrimitive.Backdrop.Props)
function DialogContent({
className,
+ overlayClassName,
children,
showCloseButton = true,
...props
-}: DialogPrimitive.Popup.Props & { showCloseButton?: boolean }) {
+}: DialogPrimitive.Popup.Props & {
+ showCloseButton?: boolean;
+ /**
+ * Restyles the backdrop behind this popup. A dialog stacked over another passes a heavier one
+ * here, so the dialog underneath reads as background rather than as a competing surface.
+ *
+ * Setting this also forces the backdrop to exist: Base UI skips backdrops on nested dialogs,
+ * and a stacked dialog is precisely the caller that asks for one.
+ */
+ overlayClassName?: string;
+}) {
return (
<DialogPortal>
- <DialogOverlay />
+ <DialogOverlay
+ className={overlayClassName}
+ forceRender={overlayClassName !== undefined}
+ />
<DialogPrimitive.Popup
data-slot="dialog-content"
className={cn(
diff --git a/app/src/components/ui/questionnaire.tsx b/app/src/components/ui/questionnaire.tsx
new file mode 100644
index 00000000..d5928f79
--- /dev/null
+++ b/app/src/components/ui/questionnaire.tsx
@@ -0,0 +1,322 @@
+import * as React from "react"
+import { Questionnaire as QuestionnairePrimitive } from "@shadcn/react/questionnaire"
+
+import { cn } from "@/lib/utils"
+import { buttonVariants, type Button } from "@/components/ui/button"
+import { IconCheck } from "@tabler/icons-react"
+
+function Questionnaire({
+ className,
+ ...props
+}: React.ComponentProps<typeof QuestionnairePrimitive.Root>) {
+ return (
+ <QuestionnairePrimitive.Root
+ data-slot="questionnaire"
+ className={cn("flex w-full min-w-0 flex-col gap-4", className)}
+ {...props}
+ />
+ )
+}
+
+function QuestionnaireProgress({
+ className,
+ ...props
+}: React.ComponentProps<typeof QuestionnairePrimitive.Progress>) {
+ return (
+ <QuestionnairePrimitive.Progress
+ data-slot="questionnaire-progress"
+ className={cn(
+ "min-h-[1lh] w-fit min-w-[14ch] text-xs font-medium text-muted-foreground tabular-nums",
+ className
+ )}
+ {...props}
+ />
+ )
+}
+
+function QuestionnaireItem({
+ className,
+ ...props
+}: React.ComponentProps<typeof QuestionnairePrimitive.Item>) {
+ return (
+ <QuestionnairePrimitive.Item
+ data-slot="questionnaire-item"
+ className={cn(
+ "flex min-w-0 flex-col gap-4 border-0 p-0 outline-none",
+ className
+ )}
+ {...props}
+ />
+ )
+}
+
+function QuestionnaireTitle({
+ className,
+ ...props
+}: React.ComponentProps<typeof QuestionnairePrimitive.Title>) {
+ return (
+ <QuestionnairePrimitive.Title
+ data-slot="questionnaire-title"
+ className={cn(
+ "font-heading text-base leading-snug font-medium text-pretty [&:not(:has(~[data-slot=questionnaire-description]))]:mb-4",
+ className
+ )}
+ {...props}
+ />
+ )
+}
+
+function QuestionnaireDescription({
+ className,
+ ...props
+}: React.ComponentProps<typeof QuestionnairePrimitive.Description>) {
+ return (
+ <QuestionnairePrimitive.Description
+ data-slot="questionnaire-description"
+ className={cn("text-sm text-pretty text-muted-foreground", className)}
+ {...props}
+ />
+ )
+}
+
+function QuestionnaireChoices({
+ className,
+ ...props
+}: React.ComponentProps<typeof QuestionnairePrimitive.Choices>) {
+ return (
+ <QuestionnairePrimitive.Choices
+ data-slot="questionnaire-choices"
+ className={cn(
+ "group/questionnaire-choices grid min-w-0 gap-2",
+ className
+ )}
+ {...props}
+ />
+ )
+}
+
+function QuestionnaireChoice({
+ children,
+ className,
+ ...props
+}: React.ComponentProps<typeof QuestionnairePrimitive.Choice>) {
+ return (
+ <QuestionnairePrimitive.Choice
+ data-slot="questionnaire-choice"
+ className={cn(
+ "group/questionnaire-choice relative flex min-h-11 cursor-pointer items-start gap-2.5 rounded-lg border border-input bg-transparent px-3 py-2.5 text-start text-sm transition-colors outline-none select-none hover:bg-muted/50 has-[>input:focus-visible]:border-ring has-[>input:focus-visible]:ring-3 has-[>input:focus-visible]:ring-ring/50 data-invalid:border-destructive dark:bg-input/20 data-checked:border-primary/40 data-checked:bg-muted dark:data-checked:bg-muted",
+ "data-disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50",
+ className
+ )}
+ {...props}
+ >
+ <QuestionnairePrimitive.ChoiceInput
+ data-slot="questionnaire-choice-input"
+ className="absolute inset-0 z-10 size-full cursor-pointer opacity-0"
+ />
+ <span
+ aria-hidden="true"
+ data-slot="questionnaire-choice-indicator"
+ className="pointer-events-none relative flex size-4 shrink-0 translate-y-[--spacing(0.45)] items-center justify-center rounded-[4px] border border-input group-has-data-[slot=questionnaire-choice-description]/questionnaire-choice:translate-y-0.5 group-data-[type=radio]/questionnaire-choice:rounded-full group-data-checked/questionnaire-choice:border-primary group-data-checked/questionnaire-choice:bg-primary group-data-checked/questionnaire-choice:text-primary-foreground dark:bg-input/30 dark:group-data-checked/questionnaire-choice:bg-primary"
+ >
+ <span
+ data-slot="questionnaire-choice-indicator-dot"
+ className="hidden size-2 rounded-full bg-primary-foreground group-data-[type=checkbox]/questionnaire-choice:hidden group-data-checked/questionnaire-choice:block"
+ />
+ <IconCheck data-slot="questionnaire-choice-indicator-check" className="hidden size-3.5 group-data-[type=radio]/questionnaire-choice:hidden group-data-checked/questionnaire-choice:block" />
+ </span>
+ <QuestionnairePrimitive.ChoiceLabel
+ data-slot="questionnaire-choice-label"
+ className="flex min-w-0 flex-1 flex-col gap-0.5 leading-snug"
+ >
+ {children}
+ </QuestionnairePrimitive.ChoiceLabel>
+ <QuestionnairePrimitive.ChoiceShortcut
+ data-slot="questionnaire-choice-shortcut"
+ className="pointer-events-none ms-auto hidden size-5 shrink-0 translate-y-[--spacing(0.45)] items-center justify-center rounded-md border border-input bg-background font-mono text-[0.625rem] leading-none font-medium text-muted-foreground group-has-data-[slot=questionnaire-choice-description]/questionnaire-choice:translate-y-0.5 group-data-[shortcut]/questionnaire-choice:inline-flex"
+ />
+ </QuestionnairePrimitive.Choice>
+ )
+}
+
+function QuestionnaireChoiceDescription({
+ className,
+ ...props
+}: React.ComponentProps<"span">) {
+ return (
+ <span
+ data-slot="questionnaire-choice-description"
+ className={cn("text-muted-foreground", className)}
+ {...props}
+ />
+ )
+}
+
+function QuestionnaireInput({
+ className,
+ ...props
+}: React.ComponentProps<typeof QuestionnairePrimitive.Input>) {
+ return (
+ <div
+ data-slot="questionnaire-input-wrapper"
+ className="group/questionnaire-input relative w-full min-w-0"
+ >
+ <QuestionnairePrimitive.Input
+ data-slot="questionnaire-input"
+ className={cn(
+ "h-8 min-h-11 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-[color,box-shadow,background-color] outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 sm:min-h-0 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
+ "selection:bg-primary selection:text-primary-foreground placeholder:text-muted-foreground",
+ className
+ )}
+ {...props}
+ />
+ </div>
+ )
+}
+
+function QuestionnaireError({
+ className,
+ ...props
+}: React.ComponentProps<typeof QuestionnairePrimitive.Error>) {
+ return (
+ <QuestionnairePrimitive.Error
+ data-slot="questionnaire-error"
+ className={cn("mt-2 text-sm text-destructive", className)}
+ {...props}
+ />
+ )
+}
+
+function QuestionnaireActions({
+ className,
+ ...props
+}: React.ComponentProps<"div">) {
+ return (
+ <div
+ data-slot="questionnaire-actions"
+ className={cn(
+ "grid min-h-11 w-full grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-2 sm:min-h-8",
+ className
+ )}
+ {...props}
+ />
+ )
+}
+
+function QuestionnairePrevious({
+ children,
+ className,
+ size = "default",
+ variant = "outline",
+ ...props
+}: React.ComponentProps<typeof QuestionnairePrimitive.Previous> &
+ Pick<React.ComponentProps<typeof Button>, "size" | "variant">) {
+ return (
+ <QuestionnairePrimitive.Previous
+ data-slot="questionnaire-previous"
+ data-size={size}
+ data-variant={variant}
+ className={cn(
+ buttonVariants({ size, variant }),
+ "col-start-1 row-start-1 min-h-11 justify-self-start sm:min-h-0",
+ className
+ )}
+ {...props}
+ >
+ {children ?? "Previous"}
+ </QuestionnairePrimitive.Previous>
+ )
+}
+
+function QuestionnaireSkip({
+ children,
+ className,
+ size = "default",
+ variant = "outline",
+ ...props
+}: React.ComponentProps<typeof QuestionnairePrimitive.Skip> &
+ Pick<React.ComponentProps<typeof Button>, "size" | "variant">) {
+ return (
+ <QuestionnairePrimitive.Skip
+ data-slot="questionnaire-skip"
+ data-size={size}
+ data-variant={variant}
+ className={cn(
+ buttonVariants({ size, variant }),
+ "col-start-2 row-start-1 min-h-11 justify-self-end sm:min-h-0",
+ className
+ )}
+ {...props}
+ >
+ {children ?? "Skip"}
+ </QuestionnairePrimitive.Skip>
+ )
+}
+
+function QuestionnaireNext({
+ children,
+ className,
+ size = "default",
+ variant = "default",
+ ...props
+}: React.ComponentProps<typeof QuestionnairePrimitive.Next> &
+ Pick<React.ComponentProps<typeof Button>, "size" | "variant">) {
+ return (
+ <QuestionnairePrimitive.Next
+ data-slot="questionnaire-next"
+ data-size={size}
+ data-variant={variant}
+ className={cn(
+ buttonVariants({ size, variant }),
+ "col-start-3 row-start-1 min-h-11 justify-self-end sm:min-h-0",
+ className
+ )}
+ {...props}
+ >
+ {children ?? "Next"}
+ </QuestionnairePrimitive.Next>
+ )
+}
+
+function QuestionnaireSubmit({
+ children,
+ className,
+ size = "default",
+ variant = "default",
+ ...props
+}: React.ComponentProps<typeof QuestionnairePrimitive.Submit> &
+ Pick<React.ComponentProps<typeof Button>, "size" | "variant">) {
+ return (
+ <QuestionnairePrimitive.Submit
+ data-slot="questionnaire-submit"
+ data-size={size}
+ data-variant={variant}
+ className={cn(
+ buttonVariants({ size, variant }),
+ "col-start-3 row-start-1 min-h-11 justify-self-end sm:min-h-0",
+ className
+ )}
+ {...props}
+ >
+ {children ?? "Submit"}
+ </QuestionnairePrimitive.Submit>
+ )
+}
+
+export {
+ Questionnaire,
+ QuestionnaireActions,
+ QuestionnaireChoice,
+ QuestionnaireChoiceDescription,
+ QuestionnaireChoices,
+ QuestionnaireDescription,
+ QuestionnaireError,
+ QuestionnaireInput,
+ QuestionnaireItem,
+ QuestionnaireNext,
+ QuestionnairePrevious,
+ QuestionnaireProgress,
+ QuestionnaireSkip,
+ QuestionnaireSubmit,
+ QuestionnaireTitle,
+}
diff --git a/app/src/lib/agents/queries.ts b/app/src/lib/agents/queries.ts
index eadc2e20..5f2b035a 100644
--- a/app/src/lib/agents/queries.ts
+++ b/app/src/lib/agents/queries.ts
@@ -18,6 +18,15 @@ export type AgentProfile = {
visibility: AgentVisibility;
/** Where this coworker runs. Null for the Bot in the box. */
endpoint: string | null;
+ /**
+ * Whether it runs on this deployment's own Bot.
+ *
+ * Creating a coworker with no endpoint stores the deployment's managed address, so `endpoint`
+ * alone cannot tell "built-in" from "hosted by a person" — and the difference decides whether the
+ * Connection screen asks for a callback token. A built-in coworker calls tools back with the
+ * deployment's own credential and needs no setup at all.
+ */
+ builtIn: boolean;
/** Whether a key is set for it. Never the key itself. */
hasAuth: boolean;
/**
@@ -44,8 +53,27 @@ export const agentKeys = {
list: (hidden = false) => ["agents", "list", { hidden }] as const,
detail: (agentId: string) => ["agents", "detail", agentId] as const,
handoff: (agentId: string) => ["agents", "handoff", agentId] as const,
+ capabilities: () => ["agents", "capabilities"] as const,
};
+/** What kinds of coworker this deployment can create. */
+export type AgentCapabilities = {
+ /** Whether a coworker can run on the deployment's own Bot, with no endpoint of its own. */
+ builtInAvailable: boolean;
+};
+
+export function agentCapabilitiesQueryOptions() {
+ return queryOptions({
+ queryKey: agentKeys.capabilities(),
+ queryFn: (): Promise<AgentCapabilities> =>
+ client("/api/agents/capabilities", "capabilities", {
+ fallback: "Could not load what this deployment supports",
+ }),
+ // Deployment configuration, not data: it cannot change without the server restarting.
+ staleTime: Number.POSITIVE_INFINITY,
+ });
+}
+
/** Which Bots one Bot may hand work to, and whether this deployment lets it. */
export type HandoffGrants = {
/**
@@ -59,6 +87,14 @@ export type HandoffGrants = {
canGrant: boolean;
/** Bot ids this Bot may address today. */
reachable: string[];
+ /**
+ * Whether this Bot can hold such a grant at all.
+ *
+ * The handing-on tool executes inside this deployment's own run loop, so only a Bot that runs in
+ * it can be offered one. False means every grant would be refused, and the screen should say that
+ * once instead of letting each switch bounce with the same message.
+ */
+ grantable: boolean;
};
export function agentListQueryOptions(hidden = false) {
diff --git a/app/src/lib/hotkeys/use-hotkey.ts b/app/src/lib/hotkeys/use-hotkey.ts
index 6f88ca1a..7e9f4c5e 100644
--- a/app/src/lib/hotkeys/use-hotkey.ts
+++ b/app/src/lib/hotkeys/use-hotkey.ts
@@ -1,6 +1,6 @@
import { useEffect, useRef } from "react";
-import { getHotkey, matchesHotkey } from "./hotkeys";
import type { HotkeyId } from "./hotkeys";
+import { getHotkey, matchesHotkey } from "./hotkeys";
/**
* Whether the keystroke belongs to whatever the person is typing into.
diff --git a/app/src/lib/routines/queries.ts b/app/src/lib/routines/queries.ts
index 33414c40..63320a8e 100644
--- a/app/src/lib/routines/queries.ts
+++ b/app/src/lib/routines/queries.ts
@@ -12,6 +12,8 @@ import { client } from "@/lib/client";
*/
export type RoutineRecord = {
id: string;
+ /** Which Bot carries it out, so a Bot's own dialog can show only its routines. */
+ agentId: string;
schedule: string;
timezone: string;
instruction: string;
diff --git a/app/src/routes/_authed/_app/agents/index.tsx b/app/src/routes/_authed/_app/agents/index.tsx
index 7ff455ff..dcea06e0 100644
--- a/app/src/routes/_authed/_app/agents/index.tsx
+++ b/app/src/routes/_authed/_app/agents/index.tsx
@@ -3,9 +3,8 @@ import { useQuery } from "@tanstack/react-query";
import { createFileRoute, Link } from "@tanstack/react-router";
import { z } from "zod";
import { AgentCard } from "@/components/agents/agent-card";
-import { AgentProfile as AgentProfileDetail } from "@/components/agents/agent-profile";
-import { NewAgent } from "@/components/agents/new-agent";
-import { DetailPanel } from "@/components/layout/detail-panel";
+import { AgentDialog } from "@/components/agents/agent-dialog";
+import { CreateAgentDialog } from "@/components/agents/create-agent-dialog";
import { SidebarToggleBar } from "@/components/layout/sidebar-toggle";
import { StaggerItem } from "@/components/layout/stagger";
import { Button } from "@/components/ui/button";
@@ -14,7 +13,7 @@ import { agentListQueryOptions } from "@/lib/agents/queries";
/**
* Creating and inspecting a coworker are search-parameter states so the roster remains mounted and
- * Back closes the detail pane.
+ * Back closes the dialog.
*/
const agentsSearchSchema = z.object({
new: z.boolean().optional(),
@@ -34,6 +33,11 @@ export const Route = createFileRoute("/_authed/_app/agents/")({
* out of this column at any window size, so the cards behind an open Bot overlapped each other on a
* perfectly ordinary screen. `auto-fill` tracks the container instead, which is the thing that
* actually changed.
+ *
+ * The tracks are the card's own width, not `minmax(144px,1fr)`. A `1fr` track stretches to share
+ * the container while the card inside it stays 144px, and the difference reads as a gap: at prose
+ * width that was three 190px columns holding 144px cards, so the 15px gutter looked like 61px. The
+ * home screen's Explore row is the reference — fixed cards, `gap-4`, nothing stretching.
*/
function AgentsScreen() {
const { new: isCreating, agent: selectedAgentId } = Route.useSearch();
@@ -48,17 +52,7 @@ function AgentsScreen() {
const close = () => navigate({ search: {} });
return (
- <DetailPanel
- onClose={close}
- open={showCreate || showProfile}
- detail={
- showCreate ? (
- <NewAgent />
- ) : selectedAgentId ? (
- <AgentProfileDetail agentId={selectedAgentId} />
- ) : null
- }
- >
+ <>
<SidebarToggleBar />
<div className="max-w-2xl px-4 w-full mx-auto">
<div className="mt-12 w-full max-w-2xl">
@@ -77,7 +71,7 @@ function AgentsScreen() {
</div>
<div className="flex flex-row mt-4">
{!!mine?.length && (
- <div className="grid grid-cols-[repeat(auto-fill,minmax(144px,1fr))] gap-4">
+ <div className="grid grid-cols-[repeat(auto-fill,144px)] gap-4">
{mine.map((agent, index) => {
return (
<StaggerItem index={index} key={agent.id}>
@@ -102,7 +96,7 @@ function AgentsScreen() {
</div>
<div className="mt-8 w-full max-w-2xl">
<h2 className="font-bold text-lg">Explore agents</h2>
- <div className="mt-4 grid grid-cols-[repeat(auto-fill,minmax(144px,1fr))] gap-4">
+ <div className="mt-4 grid grid-cols-[repeat(auto-fill,144px)] gap-4">
{!!explore?.length &&
explore.map((agent, index) => {
return (
@@ -116,6 +110,16 @@ function AgentsScreen() {
</div>
</div>
</div>
- </DetailPanel>
+ <CreateAgentDialog
+ onClose={close}
+ onCreated={(agentId) => navigate({ search: { agent: agentId } })}
+ open={showCreate}
+ />
+ <AgentDialog
+ agentId={selectedAgentId ?? null}
+ onClose={close}
+ open={showProfile}
+ />
+ </>
);
}
diff --git a/server/src/agents/routes.ts b/server/src/agents/routes.ts
index 060e77af..7a230228 100644
--- a/server/src/agents/routes.ts
+++ b/server/src/agents/routes.ts
@@ -158,8 +158,39 @@ export function createAgentRoutes(
enabled: boolean;
/** The Bots this one may address today, read per call so a revoked grant stops showing. */
reachableFrom: (agentId: string) => Promise<readonly string[]>;
+ /**
+ * Whether this Bot can be a grantee at all — the handing-on tool executes inside this
+ * deployment's own run loop, so only a Bot that runs in it can be offered one. Exposed so the
+ * screen can say that once, instead of letting every switch fail with the same refusal.
+ * Optional so a caller without a plugin store answers "no" rather than crashing the read.
+ */
+ runsHere?: (agentId: string) => Promise<boolean | undefined>;
},
+ /**
+ * Whether a coworker can run on this deployment's own Bot, i.e. be created with no endpoint.
+ *
+ * The store already refuses such a create on a deployment with no managed Bot; this exists so a
+ * screen can say so before somebody fills in three steps of a form that was always going to fail.
+ */
+ builtInAvailable = false,
+ /**
+ * The managed Bot's own address, so a coworker created without an endpoint can be told apart.
+ *
+ * Creation bakes this address into the coworker's stored configuration, and afterwards nothing in
+ * the row says whether a person supplied it. The difference matters to exactly one screen: a
+ * coworker running here calls tools back with the deployment's own credential and needs no setup,
+ * while one a person hosts needs a callback token put into their process. Without this flag the
+ * dialog nagged built-in coworkers about a credential they never needed.
+ */
+ managedEndpoint?: string,
) {
+ /** The dto with the one fact only this closure knows: whether the coworker runs on our own Bot. */
+ const dto = (actor: AgentActor, agent: AgentProfile) => ({
+ ...agentDto(actor, agent),
+ // A string comparison on purpose: two absent values must not read as "runs on our Bot".
+ builtIn:
+ typeof agent.endpoint === "string" && agent.endpoint === managedEndpoint,
+ });
const routes = new Hono<{ Variables: AppVariables }>();
/**
@@ -215,13 +246,23 @@ export function createAgentRoutes(
const hidden = context.req.query("hidden") === "true";
const agents = await store.list(context.var.actor, hidden);
return context.json({
- agents: agents.map((agent) => agentDto(context.var.actor, agent)),
+ agents: agents.map((agent) => dto(context.var.actor, agent)),
});
} catch (error) {
return mapStoreError(context, error);
}
});
+ /**
+ * What kinds of coworker this deployment can create, for the screen that asks.
+ *
+ * Static per process: whether a managed Bot exists is deployment configuration, not data. Above
+ * the parameterised route on purpose, so "capabilities" can never be read as an agent id.
+ */
+ routes.get("/capabilities", requireUser, (context) =>
+ context.json({ capabilities: { builtInAvailable } }),
+ );
+
routes.get("/:agentId", requireUser, async (context) => {
try {
const agent = await store.get(
@@ -231,7 +272,7 @@ export function createAgentRoutes(
if (!agent) {
return context.json({ error: "Agent not found." }, 404);
}
- return context.json({ agent: agentDto(context.var.actor, agent) });
+ return context.json({ agent: dto(context.var.actor, agent) });
} catch (error) {
return mapStoreError(context, error);
}
@@ -323,7 +364,7 @@ export function createAgentRoutes(
...(parsed.value.endpoint ? { endpoint: parsed.value.endpoint } : {}),
hasKey: Boolean(parsed.value.auth),
});
- return context.json({ agent: agentDto(context.var.actor, agent) }, 201);
+ return context.json({ agent: dto(context.var.actor, agent) }, 201);
} catch (error) {
return mapStoreError(context, error);
}
@@ -351,7 +392,7 @@ export function createAgentRoutes(
...(parsed.value.endpoint ? { endpoint: parsed.value.endpoint } : {}),
...(parsed.value.auth ? { keyReplaced: true } : {}),
});
- return context.json({ agent: agentDto(context.var.actor, agent) });
+ return context.json({ agent: dto(context.var.actor, agent) });
} catch (error) {
return mapStoreError(context, error);
}
@@ -368,7 +409,7 @@ export function createAgentRoutes(
await record(context, "bot.duplicated", agent.id, {
copiedFrom: context.req.param("agentId"),
});
- return context.json({ agent: agentDto(context.var.actor, agent) }, 201);
+ return context.json({ agent: dto(context.var.actor, agent) }, 201);
} catch (error) {
return mapStoreError(context, error);
}
@@ -481,6 +522,11 @@ export function createAgentRoutes(
// Granting is an administrator's, the same as it is on every other grant.
canGrant: context.var.actor.role === "admin",
reachable: handoff ? await handoff.reachableFrom(agentId) : [],
+ // Whether this Bot can hold such a grant at all; the write path refuses one that cannot,
+ // and the screen should say so before a person flips switches that can only bounce.
+ grantable: handoff?.runsHere
+ ? ((await handoff.runsHere(agentId)) ?? false)
+ : false,
},
});
} catch (error) {
diff --git a/server/src/app.ts b/server/src/app.ts
index 65bfd5ff..ff81b178 100644
--- a/server/src/app.ts
+++ b/server/src/app.ts
@@ -842,8 +842,16 @@ export function createApp(
config.handoff.maxDepth > 0 && config.handoff.maxPerRun > 0,
reachableFrom: (agentId) =>
pluginStore.botsReachableFrom(agentId),
+ // The same answer the write path checks, read up front so the screen can say it once.
+ runsHere: (agentId) => pluginStore.agentRunsHere(agentId),
}
: undefined,
+ // Whether "built-in" is a kind of coworker this deployment can actually make: the create
+ // path falls back to the managed Bot's endpoint, so without one it can only refuse.
+ config.managedAgent !== undefined,
+ // The managed Bot's address, so a coworker created without an endpoint — which creation
+ // stores as running at this address — can be told apart from one a person hosts.
+ config.managedAgent?.endpoint.toString(),
),
);
// Choosing a coworker for an untagged message needs the same permission-filtered roster the
diff --git a/server/src/routines/routes.ts b/server/src/routines/routes.ts
index f723c43d..e343e487 100644
--- a/server/src/routines/routes.ts
+++ b/server/src/routines/routes.ts
@@ -83,6 +83,8 @@ export function createRoutineRoutes(
*/
type RoutineDto = {
id: string;
+ /** Which Bot carries it out, so a Bot's own screen can show only its routines. */
+ agentId: string;
schedule: string;
timezone: string;
instruction: string;
@@ -95,6 +97,7 @@ type RoutineDto = {
function routineDto(routine: RoutineSummary): RoutineDto {
return {
id: routine.id,
+ agentId: routine.agentId,
schedule: routine.schedule,
timezone: routine.timezone,
instruction: routine.instruction,
diff --git a/server/tests/agent-routes.test.ts b/server/tests/agent-routes.test.ts
index 73fc40af..6eaab5fb 100644
--- a/server/tests/agent-routes.test.ts
+++ b/server/tests/agent-routes.test.ts
@@ -344,6 +344,7 @@ describe("agent lifecycle routes", () => {
systemOwned: false,
canManage: true,
mine: true,
+ builtIn: false,
},
{
id: "agent-2",
@@ -356,6 +357,7 @@ describe("agent lifecycle routes", () => {
systemOwned: false,
canManage: false,
mine: false,
+ builtIn: false,
},
{
id: "system-agent",
@@ -368,6 +370,7 @@ describe("agent lifecycle routes", () => {
systemOwned: true,
canManage: false,
mine: false,
+ builtIn: false,
},
],
});
@@ -662,6 +665,8 @@ describe("which Bots a Bot may hand work to", () => {
enabled: true,
canGrant: true,
reachable: ["knowledge"],
+ // No runsHere reader was wired, and a Bot nothing can vouch for is not offered grants.
+ grantable: false,
});
});
diff --git a/server/tests/routine-routes.test.ts b/server/tests/routine-routes.test.ts
index c069400f..b4849bf6 100644
--- a/server/tests/routine-routes.test.ts
+++ b/server/tests/routine-routes.test.ts
@@ -117,6 +117,7 @@ describe("GET /", () => {
routines: [
{
id: "routine-1",
+ agentId: "agent-1",
schedule: "Weekdays at 09:00",
timezone: "UTC",
instruction: "Post the weather every weekday morning.",