Skip to content

Build and run agents you can see, understand and trust.

feat(webui): add resizable right panel to display task, permission context, MCP and skills (#1945)

DavdGao4ae6f37f08e1
diff --git a/examples/web_ui/frontend/package.json b/examples/web_ui/frontend/package.json
index 340d0349d..b7ae216c3 100644
--- a/examples/web_ui/frontend/package.json
+++ b/examples/web_ui/frontend/package.json
@@ -11,7 +11,7 @@
"preview": "vite preview"
},
"dependencies": {
- "@agentscope-ai/agentscope": "^0.0.11",
+ "@agentscope-ai/agentscope": "^0.0.12",
"@fontsource-variable/geist": "^5.2.8",
"@tailwindcss/vite": "^4.3.0",
"class-variance-authority": "^0.7.1",
@@ -33,6 +33,7 @@
"react-dom": "^19.2.6",
"react-i18next": "^17.0.8",
"react-markdown": "^10.1.0",
+ "react-resizable-panels": "^4.11.2",
"react-router-dom": "^7.15.1",
"remark-gfm": "^4.0.1",
"shadcn": "^4.7.0",
diff --git a/examples/web_ui/frontend/src/components/chat/TextInput.tsx b/examples/web_ui/frontend/src/components/chat/TextInput.tsx
index f48661df2..bd4fa0d60 100644
--- a/examples/web_ui/frontend/src/components/chat/TextInput.tsx
+++ b/examples/web_ui/frontend/src/components/chat/TextInput.tsx
@@ -266,7 +266,7 @@ export const TextInput = forwardRef<TextInputRef, TextInputProps>(
onBlur={() => setIsFocused(false)}
placeholder={defaultPlaceholder}
disabled={disabled}
- rows={3}
+ rows={1}
className="w-full resize-none rounded-md border-0 bg-transparent px-3 py-2 text-sm outline-none placeholder:text-muted-foreground focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
style={{
maxHeight: 'calc(1.5em * 6)',
diff --git a/examples/web_ui/frontend/src/components/drawer/WorkspaceDrawer.tsx b/examples/web_ui/frontend/src/components/drawer/WorkspaceDrawer.tsx
deleted file mode 100644
index a9e5b6515..000000000
--- a/examples/web_ui/frontend/src/components/drawer/WorkspaceDrawer.tsx
+++ /dev/null
@@ -1,235 +0,0 @@
-import { Search, Trash, PlusCircle } from 'lucide-react';
-import { type ReactNode, useState } from 'react';
-
-import type { MCPClient, MCPClientStatus, Skill } from '@/api';
-import { AddSkillDialog } from '@/components/dialog/AddSkillDialog.tsx';
-import { DeleteDialog } from '@/components/dialog/DeleteDialog.tsx';
-import { CreateMCPDialog } from '@/components/dialog/MCPDialog.tsx';
-import { Button } from '@/components/ui/button';
-import {
- Drawer,
- DrawerContent,
- DrawerDescription,
- DrawerFooter,
- DrawerHeader,
- DrawerTitle,
- DrawerTrigger,
-} from '@/components/ui/drawer';
-import { InputGroup, InputGroupAddon, InputGroupInput } from '@/components/ui/input-group';
-import { Item, ItemActions, ItemContent, ItemDescription, ItemTitle } from '@/components/ui/item';
-import { Kbd, KbdGroup } from '@/components/ui/kbd';
-import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs.tsx';
-import { useTranslation } from '@/i18n/useI18n.ts';
-
-interface WorkspaceDrawerProps {
- children: ReactNode;
- mcps: MCPClientStatus[];
- loading?: boolean;
- onAdd: (mcps: MCPClient[]) => Promise<void>;
- onRemove: (name: string) => Promise<void>;
- skills: Skill[];
- skillsLoading?: boolean;
- onAddSkill: (skillPath: string) => Promise<void>;
- onRemoveSkill: (name: string) => Promise<void>;
-}
-
-export function WorkspaceDrawer({
- children,
- mcps,
- loading = false,
- onAdd,
- onRemove,
- skills,
- skillsLoading = false,
- onAddSkill,
- onRemoveSkill,
-}: WorkspaceDrawerProps) {
- const { t } = useTranslation();
- const [search, setSearch] = useState('');
- const [skillSearch, setSkillSearch] = useState('');
- const [activeTab, setActiveTab] = useState('mcp');
- const [deleteOpen, setDeleteOpen] = useState(false);
- const [deleteTarget, setDeleteTarget] = useState<string | null>(null);
- const [skillDeleteOpen, setSkillDeleteOpen] = useState(false);
- const [skillDeleteTarget, setSkillDeleteTarget] = useState<string | null>(null);
-
- const filtered = search
- ? mcps.filter((m) => m.name.toLowerCase().includes(search.toLowerCase()))
- : mcps;
-
- const filteredSkills = skillSearch
- ? skills.filter((s) => s.name.toLowerCase().includes(skillSearch.toLowerCase()))
- : skills;
-
- return (
- <Drawer direction="right">
- <DrawerTrigger asChild>{children}</DrawerTrigger>
- <DrawerContent>
- <DrawerHeader>
- <DrawerTitle>Workspace</DrawerTitle>
- <DrawerDescription>Where the agent works.</DrawerDescription>
- </DrawerHeader>
- <div className="flex flex-col no-scrollbar overflow-y-auto px-4 gap-y-2">
- <Tabs defaultValue="mcp" onValueChange={setActiveTab}>
- <TabsList className={'w-full'}>
- <TabsTrigger value={'mcp'}>MCP</TabsTrigger>
- <TabsTrigger value={'skill'}>SKILL</TabsTrigger>
- </TabsList>
- <TabsContent value={'mcp'} asChild>
- <div className="flex flex-col no-scrollbar overflow-y-auto gap-y-2">
- <span className={'text-muted-foreground text-sm'}>
- The MCP servers equipped in the workspace.
- </span>
- <InputGroup className="mt-4">
- <InputGroupInput
- placeholder="Search MCP in the workspace"
- value={search}
- onChange={(e) => setSearch(e.target.value)}
- />
- <InputGroupAddon align="inline-end">
- <Search />
- </InputGroupAddon>
- </InputGroup>
- {loading ? (
- <p className="text-muted-foreground text-sm text-center py-4">
- Loading…
- </p>
- ) : filtered.length === 0 ? (
- <p className="text-muted-foreground text-sm text-center py-4">
- No MCPs found
- </p>
- ) : (
- filtered.map((mcp) => (
- <Item key={mcp.name} variant="outline">
- <ItemContent>
- <ItemTitle className="flex items-center gap-x-2">
- <span
- className={`size-2 shrink-0 rounded-full ${mcp.is_healthy ? 'bg-green-500' : 'bg-red-500'}`}
- />
- {mcp.name}
- </ItemTitle>
- <ItemDescription>
- <KbdGroup>
- <Kbd>
- {mcp.mcp_config.type === 'stdio_mcp'
- ? 'STDIO'
- : 'HTTP'}
- </Kbd>
- <Kbd>{mcp.tools.length} tools</Kbd>
- </KbdGroup>
- </ItemDescription>
- </ItemContent>
- <ItemActions>
- <Button
- variant="outline"
- size="icon-sm"
- onClick={() => {
- setDeleteTarget(mcp.name);
- setDeleteOpen(true);
- }}
- >
- <Trash />
- </Button>
- </ItemActions>
- </Item>
- ))
- )}
- </div>
- </TabsContent>
- <TabsContent value={'skill'} asChild>
- <div className="flex flex-col no-scrollbar overflow-y-auto gap-y-2">
- <span className={'text-muted-foreground text-sm'}>
- The skills equipped in the workspace.
- </span>
- <InputGroup className="mt-4">
- <InputGroupInput
- placeholder="Search skills in the workspace"
- value={skillSearch}
- onChange={(e) => setSkillSearch(e.target.value)}
- />
- <InputGroupAddon align="inline-end">
- <Search />
- </InputGroupAddon>
- </InputGroup>
- {skillsLoading ? (
- <p className="text-muted-foreground text-sm text-center py-4">
- Loading…
- </p>
- ) : filteredSkills.length === 0 ? (
- <p className="text-muted-foreground text-sm text-center py-4">
- No skills found
- </p>
- ) : (
- filteredSkills.map((skill) => (
- <Item key={skill.name} variant="outline">
- <ItemContent>
- <ItemTitle>{skill.name}</ItemTitle>
- <ItemDescription>
- {skill.description}
- </ItemDescription>
- </ItemContent>
- <ItemActions>
- <Button
- variant="outline"
- size="icon-sm"
- onClick={() => {
- setSkillDeleteTarget(skill.name);
- setSkillDeleteOpen(true);
- }}
- >
- <Trash />
- </Button>
- </ItemActions>
- </Item>
- ))
- )}
- </div>
- </TabsContent>
- </Tabs>
- </div>
-
- <DrawerFooter>
- {activeTab === 'mcp' ? (
- <CreateMCPDialog onAdd={onAdd}>
- <Button variant="default">
- <PlusCircle />
- Add MCP
- </Button>
- </CreateMCPDialog>
- ) : (
- <AddSkillDialog onAdd={onAddSkill}>
- <Button variant="default">
- <PlusCircle />
- Add Skill
- </Button>
- </AddSkillDialog>
- )}
- </DrawerFooter>
- </DrawerContent>
- <DeleteDialog
- open={deleteOpen}
- onOpenChange={setDeleteOpen}
- title={t('common.deleteTitle', {
- entity: t('dialog-mcp-delete.entity'),
- name: deleteTarget ?? '',
- })}
- description={t('common.deleteDescription')}
- onConfirm={async () => {
- if (deleteTarget) await onRemove(deleteTarget);
- }}
- />
- <DeleteDialog
- open={skillDeleteOpen}
- onOpenChange={setSkillDeleteOpen}
- title={t('common.deleteTitle', {
- entity: t('dialog-mcp-delete.skillEntity'),
- name: skillDeleteTarget ?? '',
- })}
- description={t('dialog-mcp-delete.skillDescription')}
- onConfirm={async () => {
- if (skillDeleteTarget) await onRemoveSkill(skillDeleteTarget);
- }}
- />
- </Drawer>
- );
-}
diff --git a/examples/web_ui/frontend/src/components/panel/McpPanel.tsx b/examples/web_ui/frontend/src/components/panel/McpPanel.tsx
new file mode 100644
index 000000000..bcbca7398
--- /dev/null
+++ b/examples/web_ui/frontend/src/components/panel/McpPanel.tsx
@@ -0,0 +1,146 @@
+import { PlusCircle, Search, SearchX, Trash, Unplug } from 'lucide-react';
+import { useState } from 'react';
+
+import type { MCPClient, MCPClientStatus } from '@/api';
+import { DeleteDialog } from '@/components/dialog/DeleteDialog.tsx';
+import { CreateMCPDialog } from '@/components/dialog/MCPDialog.tsx';
+import { PanelEmpty } from '@/components/panel/PanelEmpty';
+import { Button } from '@/components/ui/button';
+import { InputGroup, InputGroupAddon, InputGroupInput } from '@/components/ui/input-group';
+import { Item, ItemActions, ItemContent, ItemDescription, ItemTitle } from '@/components/ui/item';
+import { Kbd, KbdGroup } from '@/components/ui/kbd';
+import { useTranslation } from '@/i18n/useI18n.ts';
+
+interface McpPanelProps {
+ /** The MCP servers equipped in the workspace. */
+ mcps: MCPClientStatus[];
+ /** Whether the MCP list is still loading. */
+ loading?: boolean;
+ /**
+ * Add one or more MCP servers to the workspace.
+ *
+ * @param mcps - The MCP client configs to add.
+ */
+ onAdd: (mcps: MCPClient[]) => Promise<void>;
+ /**
+ * Remove an MCP server by name.
+ *
+ * @param name - The MCP server name to remove.
+ */
+ onRemove: (name: string) => Promise<void>;
+}
+
+/**
+ * Pure content body for the MCP dock panel: a search box, the list of
+ * equipped MCP servers, and an "Add MCP" action. Holds only local UI
+ * state (search text, delete confirmation target); all data arrives
+ * via props so it owns no data fetching.
+ *
+ * Renders without its own header/border — the surrounding `Panel`
+ * chrome (from `PanelDock`) provides those.
+ *
+ * @param mcps - The MCP servers to list.
+ * @param loading - Whether the list is loading.
+ * @param onAdd - Add-MCP callback.
+ * @param onRemove - Remove-MCP callback.
+ * @returns The MCP panel body.
+ */
+export function McpPanel({ mcps, loading = false, onAdd, onRemove }: McpPanelProps) {
+ const { t } = useTranslation();
+ const [search, setSearch] = useState('');
+ const [deleteOpen, setDeleteOpen] = useState(false);
+ const [deleteTarget, setDeleteTarget] = useState<string | null>(null);
+
+ const filtered = search
+ ? mcps.filter((m) => m.name.toLowerCase().includes(search.toLowerCase()))
+ : mcps;
+
+ return (
+ <div className="flex flex-col flex-1 min-h-0 gap-y-2">
+ <span className="text-muted-foreground text-sm">{t('panel.mcp.description')}</span>
+ <InputGroup>
+ <InputGroupInput
+ placeholder={t('panel.mcp.searchPlaceholder')}
+ value={search}
+ onChange={(e) => setSearch(e.target.value)}
+ />
+ <InputGroupAddon align="inline-end">
+ <Search />
+ </InputGroupAddon>
+ </InputGroup>
+
+ {loading ? (
+ <div className="flex flex-1 items-center justify-center">
+ <p className="text-muted-foreground text-sm">{t('panel.loading')}</p>
+ </div>
+ ) : filtered.length === 0 ? (
+ <PanelEmpty
+ icon={search ? SearchX : Unplug}
+ title={search ? t('panel.search.emptyTitle') : t('panel.mcp.emptyTitle')}
+ description={
+ search
+ ? t('panel.search.emptyDescription', { query: search })
+ : t('panel.mcp.emptyDescription')
+ }
+ />
+ ) : (
+ <div className="flex flex-col flex-1 min-h-0 overflow-y-auto gap-y-2">
+ {filtered.map((mcp) => (
+ <Item key={mcp.name} variant="outline">
+ <ItemContent>
+ <ItemTitle className="flex items-center gap-x-2">
+ <span
+ className={`size-2 shrink-0 rounded-full ${mcp.is_healthy ? 'bg-green-500' : 'bg-red-500'}`}
+ />
+ {mcp.name}
+ </ItemTitle>
+ <ItemDescription>
+ <KbdGroup>
+ <Kbd>
+ {mcp.mcp_config.type === 'stdio_mcp' ? 'STDIO' : 'HTTP'}
+ </Kbd>
+ <Kbd>
+ {t('panel.mcp.tools', { count: mcp.tools.length })}
+ </Kbd>
+ </KbdGroup>
+ </ItemDescription>
+ </ItemContent>
+ <ItemActions>
+ <Button
+ variant="outline"
+ size="icon-sm"
+ onClick={() => {
+ setDeleteTarget(mcp.name);
+ setDeleteOpen(true);
+ }}
+ >
+ <Trash />
+ </Button>
+ </ItemActions>
+ </Item>
+ ))}
+ </div>
+ )}
+
+ <CreateMCPDialog onAdd={onAdd}>
+ <Button variant="default">
+ <PlusCircle />
+ {t('panel.mcp.add')}
+ </Button>
+ </CreateMCPDialog>
+
+ <DeleteDialog
+ open={deleteOpen}
+ onOpenChange={setDeleteOpen}
+ title={t('common.deleteTitle', {
+ entity: t('dialog-mcp-delete.entity'),
+ name: deleteTarget ?? '',
+ })}
+ description={t('common.deleteDescription')}
+ onConfirm={async () => {
+ if (deleteTarget) await onRemove(deleteTarget);
+ }}
+ />
+ </div>
+ );
+}
diff --git a/examples/web_ui/frontend/src/components/panel/PanelDock.tsx b/examples/web_ui/frontend/src/components/panel/PanelDock.tsx
new file mode 100644
index 000000000..f32d97733
--- /dev/null
+++ b/examples/web_ui/frontend/src/components/panel/PanelDock.tsx
@@ -0,0 +1,161 @@
+import { X } from 'lucide-react';
+import { Fragment, type ReactNode } from 'react';
+
+import { Button } from '@/components/ui/button.tsx';
+import {
+ ResizableHandle,
+ ResizablePanel,
+ ResizablePanelGroup,
+} from '@/components/ui/resizable.tsx';
+
+/**
+ * Identifier for a dockable panel. Used both as the React key and to
+ * look its descriptor up in {@link PanelDockProps.panels}.
+ */
+export type PanelKey = 'plan' | 'mcp' | 'skill' | 'permission';
+
+/**
+ * The presentation of a single panel: header chrome plus its already
+ * data-bound content node. Built by the owner (ChatViewport) so that
+ * the dock itself stays free of any business/data dependency.
+ */
+export interface PanelDescriptor {
+ /** Header title shown in the panel's chrome. */
+ title: ReactNode;
+ /** Optional leading icon shown next to the title. */
+ icon?: ReactNode;
+ /**
+ * The panel body. Constructed by the owner with live data
+ * (e.g. `<TaskPanel tasksContext={...} />`) so it always reflects
+ * the latest state on every owner re-render.
+ */
+ content: ReactNode;
+}
+
+interface PanelDockProps {
+ /**
+ * Controlled layout state. Outer array = columns (laid out left to
+ * right), inner array = the panels stacked top to bottom within a
+ * column (max 2). The dock never mutates this; it only renders it.
+ */
+ layout: PanelKey[][];
+ /**
+ * Lookup from {@link PanelKey} to its {@link PanelDescriptor}. Only
+ * needs to contain keys that may appear in {@link layout}.
+ */
+ panels: Record<PanelKey, PanelDescriptor>;
+ /**
+ * Invoked when a panel's close button is clicked. The owner is
+ * responsible for removing the key from {@link layout} (and dropping
+ * the column if it becomes empty).
+ *
+ * @param key - The panel being closed.
+ */
+ onClosePanel: (key: PanelKey) => void;
+}
+
+/**
+ * Minimum width of a dock column. Keeps a panel's content (search box,
+ * list items) from being squeezed unusably narrow.
+ */
+const COLUMN_MIN_WIDTH = '20rem';
+
+/**
+ * Minimum height of a single panel within a column. Guarantees the
+ * title bar plus a sliver of content stays visible.
+ */
+const PANEL_MIN_HEIGHT = '6rem';
+
+interface PanelProps {
+ title: ReactNode;
+ icon?: ReactNode;
+ onClose: () => void;
+ children: ReactNode;
+}
+
+/**
+ * Generic panel chrome: a bordered container with a title bar (icon +
+ * title + close button) and a flexible body. Content components are
+ * rendered as `children` and should not draw their own header/border.
+ *
+ * @param title - Header title.
+ * @param icon - Optional leading icon.
+ * @param onClose - Called when the close button is clicked.
+ * @param children - The panel body.
+ * @returns The panel chrome element.
+ */
+export const Panel = ({ title, icon, onClose, children }: PanelProps) => {
+ return (
+ <div className="flex flex-1 flex-col border rounded-sm h-full py-1 min-h-0">
+ <div className="flex items-center justify-between px-2">
+ <span className="flex items-center gap-x-1.5 text-sm">
+ {icon}
+ {title}
+ </span>
+ <Button variant="ghost" size="icon-sm" onClick={onClose}>
+ <X />
+ </Button>
+ </div>
+ <div className="flex flex-1 flex-col min-h-0 overflow-auto px-2">{children}</div>
+ </div>
+ );
+};
+
+/**
+ * A pure layout engine for the right-hand dockable panel area.
+ *
+ * Knows nothing about MCP / tasks / skills — it just arranges whatever
+ * panels {@link PanelDockProps.layout} describes into a grid of
+ * horizontally-resizable columns, each containing up to two
+ * vertically-resizable rows. The panel bodies arrive pre-built via
+ * {@link PanelDockProps.panels}.
+ *
+ * Rendered as a sibling of the chat panel inside the outer horizontal
+ * `ResizablePanelGroup`, so it emits one `ResizablePanel` per column
+ * (with a `ResizableHandle` between columns) to share that group.
+ *
+ * @param layout - Controlled column/panel arrangement.
+ * @param panels - Descriptor lookup for each panel key.
+ * @param onClosePanel - Close-request callback.
+ * @returns The column fragment, or `null` when no panels are open.
+ */
+export const PanelDock = ({ layout, panels, onClosePanel }: PanelDockProps) => {
+ if (layout.length === 0) return null;
+
+ return (
+ <>
+ {layout.map((column, colIndex) => (
+ <Fragment key={`col-${column.join('-')}`}>
+ {colIndex > 0 && <ResizableHandle withHandle className="bg-transparent" />}
+ <ResizablePanel className="p-1" minSize={COLUMN_MIN_WIDTH} defaultSize="22rem">
+ <ResizablePanelGroup orientation="vertical">
+ {column.map((key, rowIndex) => {
+ const descriptor = panels[key];
+ if (!descriptor) return null;
+ return (
+ <Fragment key={key}>
+ {rowIndex > 0 && (
+ <ResizableHandle
+ withHandle
+ className="bg-transparent"
+ />
+ )}
+ <ResizablePanel className="py-1" minSize={PANEL_MIN_HEIGHT}>
+ <Panel
+ title={descriptor.title}
+ icon={descriptor.icon}
+ onClose={() => onClosePanel(key)}
+ >
+ {descriptor.content}
+ </Panel>
+ </ResizablePanel>
+ </Fragment>
+ );
+ })}
+ </ResizablePanelGroup>
+ </ResizablePanel>
+ </Fragment>
+ ))}
+ </>
+ );
+};
diff --git a/examples/web_ui/frontend/src/components/panel/PanelEmpty.tsx b/examples/web_ui/frontend/src/components/panel/PanelEmpty.tsx
new file mode 100644
index 000000000..fe3032a02
--- /dev/null
+++ b/examples/web_ui/frontend/src/components/panel/PanelEmpty.tsx
@@ -0,0 +1,46 @@
+import type { LucideIcon } from 'lucide-react';
+
+import {
+ Empty,
+ EmptyDescription,
+ EmptyHeader,
+ EmptyMedia,
+ EmptyTitle,
+} from '@/components/ui/empty';
+import { cn } from '@/lib/utils';
+
+interface PanelEmptyProps {
+ /** Icon communicating the kind of emptiness (no data vs no results). */
+ icon: LucideIcon;
+ /** Short heading, e.g. "No MCP servers" or "No results". */
+ title: string;
+ /** Optional secondary explanation line. */
+ description?: string;
+ className?: string;
+}
+
+/**
+ * A reusable empty-state for dock panels. Fills the remaining vertical
+ * space and centers an icon + title + optional description. Callers
+ * distinguish a "no data yet" state from a "search found nothing"
+ * state via the {@link icon} and {@link title} they pass.
+ *
+ * @param icon - The lucide icon to show.
+ * @param title - The empty-state heading.
+ * @param description - Optional explanatory text.
+ * @param className - Extra classes for the wrapper.
+ * @returns The centered empty-state element.
+ */
+export function PanelEmpty({ icon: Icon, title, description, className }: PanelEmptyProps) {
+ return (
+ <Empty className={cn('flex-1 border-0 p-4', className)}>
+ <EmptyHeader>
+ <EmptyMedia variant="icon">
+ <Icon />
+ </EmptyMedia>
+ <EmptyTitle>{title}</EmptyTitle>
+ {description ? <EmptyDescription>{description}</EmptyDescription> : null}
+ </EmptyHeader>
+ </Empty>
+ );
+}
diff --git a/examples/web_ui/frontend/src/components/panel/PermissionPanel.tsx b/examples/web_ui/frontend/src/components/panel/PermissionPanel.tsx
new file mode 100644
index 000000000..4baf1a978
--- /dev/null
+++ b/examples/web_ui/frontend/src/components/panel/PermissionPanel.tsx
@@ -0,0 +1,213 @@
+import type { PermissionContext, PermissionRule } from '@agentscope-ai/agentscope/permission';
+import { Ban, CircleHelp, FolderOpen, ShieldCheck, ShieldX } from 'lucide-react';
+import { useEffect, useRef, useState } from 'react';
+
+import { PanelEmpty } from '@/components/panel/PanelEmpty';
+import { Badge } from '@/components/ui/badge';
+import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
+import { useTranslation } from '@/i18n/useI18n';
+
+/** The behavior keys we render sections for (excludes ``passthrough``). */
+type RuleBehavior = 'allow' | 'deny' | 'ask';
+
+interface PermissionPanelProps {
+ /**
+ * The permission context to render. Pass ``null`` when no data is
+ * available yet (renders an empty state).
+ */
+ permissionContext: PermissionContext | null;
+}
+
+/** i18n key suffix for each behavior group title. */
+const BEHAVIOR_META: Record<RuleBehavior, { i18nKey: string; icon: typeof ShieldCheck }> = {
+ allow: { i18nKey: 'panel.permission.allow', icon: ShieldCheck },
+ deny: { i18nKey: 'panel.permission.deny', icon: Ban },
+ ask: { i18nKey: 'panel.permission.ask', icon: CircleHelp },
+};
+
+/**
+ * A monospace value (a path or rule pattern) that truncates to fit its
+ * row. When (and only when) the text is actually clipped, hovering
+ * reveals the full value in a tooltip anchored to the left.
+ *
+ * @param value - The text to display.
+ * @returns The truncating value element, with a tooltip when clipped.
+ */
+function TruncatedCode({ value }: { value: string }) {
+ const ref = useRef<HTMLSpanElement>(null);
+ const [truncated, setTruncated] = useState(false);
+
+ useEffect(() => {
+ const el = ref.current;
+ if (!el) return;
+ const check = () => setTruncated(el.scrollWidth > el.clientWidth);
+ check();
+ const observer = new ResizeObserver(check);
+ observer.observe(el);
+ return () => observer.disconnect();
+ }, [value]);
+
+ return (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span ref={ref} className="min-w-0 flex-1 truncate text-left font-mono text-xs">
+ {value}
+ </span>
+ </TooltipTrigger>
+ {truncated ? (
+ <TooltipContent side="left" className="max-w-sm font-mono break-all">
+ {value}
+ </TooltipContent>
+ ) : null}
+ </Tooltip>
+ );
+}
+
+/**
+ * A single tool's rule card: a header naming the tool plus one row per
+ * matching rule (pattern on the left, source on the right).
+ *
+ * @param toolName - The tool these rules apply to.
+ * @param rules - The rules configured for this tool under one behavior.
+ * @returns The tool card element.
+ */
+function ToolRuleCard({ toolName, rules }: { toolName: string; rules: PermissionRule[] }) {
+ const { t } = useTranslation();
+ return (
+ <div className="rounded-md border">
+ <div className="flex items-center gap-x-2 border-b px-2 py-1.5 text-sm font-medium">
+ {toolName}
+ <Badge variant="secondary" className="ml-auto">
+ {rules.length}
+ </Badge>
+ </div>
+ <ul className="flex flex-col">
+ {rules.map((rule, index) => (
+ <li
+ key={`${rule.rule_content ?? '*'}-${index}`}
+ className="flex items-center justify-between gap-x-2 px-2 py-1.5 text-xs not-last:border-b"
+ >
+ {rule.rule_content ? (
+ <TruncatedCode value={rule.rule_content} />
+ ) : (
+ <span className="min-w-0 flex-1 text-muted-foreground">
+ {t('panel.permission.anyInvocation')}
+ </span>
+ )}
+ <Badge variant="outline" className="shrink-0">
+ {rule.source}
+ </Badge>
+ </li>
+ ))}
+ </ul>
+ </div>
+ );
+}
+
+/**
+ * One behavior group (allow / deny / ask): a titled section that lists
+ * a {@link ToolRuleCard} per tool that has rules under this behavior.
+ *
+ * @param behavior - The behavior category for this section.
+ * @param ruleMap - Rules keyed by tool name for this behavior.
+ * @returns The section element, or ``null`` when there are no rules.
+ */
+function BehaviorGroup({
+ behavior,
+ ruleMap,
+}: {
+ behavior: RuleBehavior;
+ ruleMap: Record<string, PermissionRule[]> | undefined;
+}) {
+ const { t } = useTranslation();
+ const entries = Object.entries(ruleMap ?? {}).filter(([, rules]) => rules.length > 0);
+ if (entries.length === 0) return null;
+
+ const meta = BEHAVIOR_META[behavior];
+ const Icon = meta.icon;
+
+ return (
+ <div className="flex flex-col gap-y-1.5">
+ <div className="flex items-center gap-x-1.5 text-xs font-medium text-muted-foreground">
+ <Icon className="size-3.5" />
+ {t(meta.i18nKey)}
+ </div>
+ {entries.map(([toolName, rules]) => (
+ <ToolRuleCard key={toolName} toolName={toolName} rules={rules} />
+ ))}
+ </div>
+ );
+}
+
+/**
+ * Pure content body for the Permission dock panel. Shows the active
+ * permission mode, the working directories in scope, and the configured
+ * rules grouped by behavior (deny / ask / allow) and then by tool. Data
+ * arrives via props so it owns no data fetching.
+ *
+ * Renders without its own header/border — the surrounding `Panel`
+ * chrome (from `PanelDock`) provides those.
+ *
+ * @param permissionContext - The permission context, or ``null``.
+ * @returns The permission panel body.
+ */
+export function PermissionPanel({ permissionContext }: PermissionPanelProps) {
+ const { t } = useTranslation();
+ const workingDirs = Object.values(permissionContext?.working_directories ?? {});
+ const hasRules =
+ Object.keys(permissionContext?.allow_rules ?? {}).length > 0 ||
+ Object.keys(permissionContext?.deny_rules ?? {}).length > 0 ||
+ Object.keys(permissionContext?.ask_rules ?? {}).length > 0;
+
+ return (
+ <div className="flex flex-col flex-1 min-h-0 gap-y-3">
+ <span className="text-muted-foreground text-sm">
+ {t('panel.permission.description')}
+ </span>
+
+ <div className="flex flex-col flex-1 min-h-0 overflow-y-auto gap-y-4">
+ {/* Working directories — always shown, with an empty state. */}
+ <div className="flex flex-col gap-y-1.5">
+ <div className="flex items-center gap-x-1.5 text-xs font-medium text-muted-foreground">
+ <FolderOpen className="size-3.5" />
+ {t('panel.permission.workingDirectories')}
+ </div>
+ {workingDirs.length === 0 ? (
+ <p className="text-muted-foreground text-xs px-1 py-2">
+ {t('panel.permission.noWorkingDirectories')}
+ </p>
+ ) : (
+ <ul className="flex flex-col rounded-md border">
+ {workingDirs.map((dir) => (
+ <li
+ key={dir.path}
+ className="flex items-center justify-between gap-x-2 px-2 py-1.5 text-xs not-last:border-b"
+ >
+ <TruncatedCode value={dir.path} />
+ <Badge variant="outline" className="shrink-0">
+ {dir.source}
+ </Badge>
+ </li>
+ ))}
+ </ul>
+ )}
+ </div>
+
+ {/* Rules grouped by behavior, then by tool. */}
+ {hasRules ? (
+ <>
+ <BehaviorGroup behavior="deny" ruleMap={permissionContext?.deny_rules} />
+ <BehaviorGroup behavior="ask" ruleMap={permissionContext?.ask_rules} />
+ <BehaviorGroup behavior="allow" ruleMap={permissionContext?.allow_rules} />
+ </>
+ ) : (
+ <PanelEmpty
+ icon={ShieldX}
+ title={t('panel.permission.emptyTitle')}
+ description={t('panel.permission.emptyDescription')}
+ />
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/examples/web_ui/frontend/src/components/panel/SkillPanel.tsx b/examples/web_ui/frontend/src/components/panel/SkillPanel.tsx
new file mode 100644
index 000000000..98593dd17
--- /dev/null
+++ b/examples/web_ui/frontend/src/components/panel/SkillPanel.tsx
@@ -0,0 +1,131 @@
+import { FileX, PlusCircle, Search, SearchX, Trash } from 'lucide-react';
+import { useState } from 'react';
+
+import type { Skill } from '@/api';
+import { AddSkillDialog } from '@/components/dialog/AddSkillDialog.tsx';
+import { DeleteDialog } from '@/components/dialog/DeleteDialog.tsx';
+import { PanelEmpty } from '@/components/panel/PanelEmpty';
+import { Button } from '@/components/ui/button';
+import { InputGroup, InputGroupAddon, InputGroupInput } from '@/components/ui/input-group';
+import { Item, ItemActions, ItemContent, ItemDescription, ItemTitle } from '@/components/ui/item';
+import { useTranslation } from '@/i18n/useI18n.ts';
+
+interface SkillPanelProps {
+ /** The skills equipped in the workspace. */
+ skills: Skill[];
+ /** Whether the skill list is still loading. */
+ loading?: boolean;
+ /**
+ * Add a skill to the workspace.
+ *
+ * @param skillPath - Path of the skill to add.
+ */
+ onAdd: (skillPath: string) => Promise<void>;
+ /**
+ * Remove a skill by name.
+ *
+ * @param name - The skill name to remove.
+ */
+ onRemove: (name: string) => Promise<void>;
+}
+
+/**
+ * Pure content body for the Skill dock panel: a search box, the list
+ * of equipped skills, and an "Add Skill" action. Holds only local UI
+ * state (search text, delete confirmation target); all data arrives
+ * via props so it owns no data fetching.
+ *
+ * Renders without its own header/border — the surrounding `Panel`
+ * chrome (from `PanelDock`) provides those.
+ *
+ * @param skills - The skills to list.
+ * @param loading - Whether the list is loading.
+ * @param onAdd - Add-skill callback.
+ * @param onRemove - Remove-skill callback.
+ * @returns The skill panel body.
+ */
+export function SkillPanel({ skills, loading = false, onAdd, onRemove }: SkillPanelProps) {
+ const { t } = useTranslation();
+ const [search, setSearch] = useState('');
+ const [deleteOpen, setDeleteOpen] = useState(false);
+ const [deleteTarget, setDeleteTarget] = useState<string | null>(null);
+
+ const filtered = search
+ ? skills.filter((s) => s.name.toLowerCase().includes(search.toLowerCase()))
+ : skills;
+
+ return (
+ <div className="flex flex-col flex-1 min-h-0 gap-y-2">
+ <span className="text-muted-foreground text-sm">{t('panel.skill.description')}</span>
+ <InputGroup>
+ <InputGroupInput
+ placeholder={t('panel.skill.searchPlaceholder')}
+ value={search}
+ onChange={(e) => setSearch(e.target.value)}
+ />
+ <InputGroupAddon align="inline-end">
+ <Search />
+ </InputGroupAddon>
+ </InputGroup>
+
+ {loading ? (
+ <div className="flex flex-1 items-center justify-center">
+ <p className="text-muted-foreground text-sm">{t('panel.loading')}</p>
+ </div>
+ ) : filtered.length === 0 ? (
+ <PanelEmpty
+ icon={search ? SearchX : FileX}
+ title={search ? t('panel.search.emptyTitle') : t('panel.skill.emptyTitle')}
+ description={
+ search
+ ? t('panel.search.emptyDescription', { query: search })
+ : t('panel.skill.emptyDescription')
+ }
+ />
+ ) : (
+ <div className="flex flex-col flex-1 min-h-0 overflow-y-auto gap-y-2">
+ {filtered.map((skill) => (
+ <Item key={skill.name} variant="outline">
+ <ItemContent>
+ <ItemTitle>{skill.name}</ItemTitle>
+ <ItemDescription>{skill.description}</ItemDescription>
+ </ItemContent>
+ <ItemActions>
+ <Button
+ variant="outline"
+ size="icon-sm"
+ onClick={() => {
+ setDeleteTarget(skill.name);
+ setDeleteOpen(true);
+ }}
+ >
+ <Trash />
+ </Button>
+ </ItemActions>
+ </Item>
+ ))}
+ </div>
+ )}
+
+ <AddSkillDialog onAdd={onAdd}>
+ <Button variant="default">
+ <PlusCircle />
+ {t('panel.skill.add')}
+ </Button>
+ </AddSkillDialog>
+
+ <DeleteDialog
+ open={deleteOpen}
+ onOpenChange={setDeleteOpen}
+ title={t('common.deleteTitle', {
+ entity: t('dialog-mcp-delete.skillEntity'),
+ name: deleteTarget ?? '',
+ })}
+ description={t('dialog-mcp-delete.skillDescription')}
+ onConfirm={async () => {
+ if (deleteTarget) await onRemove(deleteTarget);
+ }}
+ />
+ </div>
+ );
+}
diff --git a/examples/web_ui/frontend/src/components/chat/TaskPanel.tsx b/examples/web_ui/frontend/src/components/panel/TaskPanel.tsx
similarity index 86%
rename from examples/web_ui/frontend/src/components/chat/TaskPanel.tsx
rename to examples/web_ui/frontend/src/components/panel/TaskPanel.tsx
index b4cded7b8..6f465e4d2 100644
--- a/examples/web_ui/frontend/src/components/chat/TaskPanel.tsx
+++ b/examples/web_ui/frontend/src/components/panel/TaskPanel.tsx
@@ -1,7 +1,8 @@
import type { Task, TaskContext } from '@agentscope-ai/agentscope/state';
-import { Ellipsis, Loader2, Square, SquareCheck } from 'lucide-react';
+import { Ellipsis, ListX, Loader2, Square, SquareCheck } from 'lucide-react';
import { useState } from 'react';
+import { PanelEmpty } from '@/components/panel/PanelEmpty';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { useTranslation } from '@/i18n/useI18n';
@@ -87,7 +88,13 @@ export function TaskPanel({ tasksContext, className }: TaskPanelProps) {
const [expanded, setExpanded] = useState(false);
if (!tasksContext || tasksContext.tasks.length === 0) {
- return null;
+ return (
+ <PanelEmpty
+ icon={ListX}
+ title={t('panel.plan.emptyTitle')}
+ description={t('panel.plan.emptyDescription')}
+ />
+ );
}
const { tasks } = tasksContext;
@@ -97,15 +104,17 @@ export function TaskPanel({ tasksContext, className }: TaskPanelProps) {
const displayedTasks = expanded ? tasks : visibleTasks;
return (
- <div className={cn('hidden md:flex flex-col text-sm py-2 px-0', className)}>
- <div className="flex flex-row justify-between">
- <span className="font-bold text-muted-foreground">{t('task-panel.heading')}</span>
+ <div className={cn('flex flex-col flex-1 min-h-0 text-sm', className)}>
+ <div className="flex flex-row items-center gap-x-2 shrink-0 pb-2">
<Badge variant={'secondary'} className="tracking-wide">
- {completed}/{tasks.length}
+ {t('panel.plan.completed', { count: completed })}
+ </Badge>
+ <Badge variant={'secondary'} className="tracking-wide">
+ {t('panel.plan.total', { count: tasks.length })}
</Badge>
</div>
- <ul className="flex flex-col gap-y-0.5 text-xs overflow-y-auto h-full">
+ <ul className="flex flex-col flex-1 min-h-0 gap-y-0.5 text-xs overflow-y-auto">
{showEllipsis && !expanded && (
<Button
size={'xs'}
diff --git a/examples/web_ui/frontend/src/components/ui/resizable.tsx b/examples/web_ui/frontend/src/components/ui/resizable.tsx
new file mode 100644
index 000000000..f69f4a178
--- /dev/null
+++ b/examples/web_ui/frontend/src/components/ui/resizable.tsx
@@ -0,0 +1,42 @@
+import * as ResizablePrimitive from 'react-resizable-panels';
+
+import { cn } from '@/lib/utils';
+
+function ResizablePanelGroup({ className, ...props }: ResizablePrimitive.GroupProps) {
+ return (
+ <ResizablePrimitive.Group
+ data-slot="resizable-panel-group"
+ className={cn('flex h-full w-full aria-[orientation=vertical]:flex-col', className)}
+ {...props}
+ />
+ );
+}
+
+function ResizablePanel({ ...props }: ResizablePrimitive.PanelProps) {
+ return <ResizablePrimitive.Panel data-slot="resizable-panel" {...props} />;
+}
+
+function ResizableHandle({
+ withHandle,
+ className,
+ ...props
+}: ResizablePrimitive.SeparatorProps & {
+ withHandle?: boolean;
+}) {
+ return (
+ <ResizablePrimitive.Separator
+ data-slot="resizable-handle"
+ className={cn(
+ 'group relative flex w-px items-center justify-center bg-border ring-offset-background after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90',
+ className,
+ )}
+ {...props}
+ >
+ {withHandle && (
+ <div className="z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border opacity-0 transition-opacity duration-150 group-hover:opacity-100" />
+ )}
+ </ResizablePrimitive.Separator>
+ );
+}
+
+export { ResizableHandle, ResizablePanel, ResizablePanelGroup };
diff --git a/examples/web_ui/frontend/src/components/ui/toggle.tsx b/examples/web_ui/frontend/src/components/ui/toggle.tsx
new file mode 100644
index 000000000..e3ed360b8
--- /dev/null
+++ b/examples/web_ui/frontend/src/components/ui/toggle.tsx
@@ -0,0 +1,44 @@
+import * as React from 'react';
+import { cva, type VariantProps } from 'class-variance-authority';
+import { Toggle as TogglePrimitive } from 'radix-ui';
+
+import { cn } from '@/lib/utils';
+
+const toggleVariants = cva(
+ "group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ {
+ variants: {
+ variant: {
+ default: 'bg-transparent',
+ outline: 'border border-input bg-transparent hover:bg-muted',
+ },
+ size: {
+ default:
+ 'h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2',
+ sm: "h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
+ lg: 'h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2',
+ },
+ },
+ defaultVariants: {
+ variant: 'default',
+ size: 'default',
+ },
+ },
+);
+
+function Toggle({
+ className,
+ variant = 'default',
+ size = 'default',
+ ...props
+}: React.ComponentProps<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants>) {
+ return (
+ <TogglePrimitive.Root
+ data-slot="toggle"
+ className={cn(toggleVariants({ variant, size, className }))}
+ {...props}
+ />
+ );
+}
+
+export { Toggle, toggleVariants };
diff --git a/examples/web_ui/frontend/src/i18n/locales/en.json b/examples/web_ui/frontend/src/i18n/locales/en.json
index aaf23b990..cea794fd8 100644
--- a/examples/web_ui/frontend/src/i18n/locales/en.json
+++ b/examples/web_ui/frontend/src/i18n/locales/en.json
@@ -346,6 +346,50 @@
"completed": "Completed",
"blockedBy": "blocked by"
},
+ "panel": {
+ "plan": {
+ "title": "Plan",
+ "completed": "Completed: {{count}}",
+ "total": "Total: {{count}}",
+ "emptyTitle": "No tasks yet",
+ "emptyDescription": "Tasks the agent plans will show up here."
+ },
+ "mcp": {
+ "title": "MCP",
+ "description": "The MCP servers equipped in the workspace.",
+ "searchPlaceholder": "Search MCP in the workspace",
+ "add": "Add MCP",
+ "tools": "{{count}} tools",
+ "emptyTitle": "No MCP servers",
+ "emptyDescription": "Add an MCP server to equip the workspace with tools."
+ },
+ "skill": {
+ "title": "Skills",
+ "description": "The skills equipped in the workspace.",
+ "searchPlaceholder": "Search skills in the workspace",
+ "add": "Add Skill",
+ "emptyTitle": "No skills",
+ "emptyDescription": "Add a skill to equip the workspace."
+ },
+ "permission": {
+ "title": "Permissions",
+ "description": "The permissions applied in this session.",
+ "mode": "Mode: {{mode}}",
+ "workingDirectories": "Working Directories",
+ "noWorkingDirectories": "No working directories.",
+ "allow": "Allow",
+ "deny": "Deny",
+ "ask": "Ask",
+ "anyInvocation": "any invocation",
+ "emptyTitle": "No rules configured",
+ "emptyDescription": "Allow / deny / ask rules will appear here as they are added."
+ },
+ "search": {
+ "emptyTitle": "No results",
+ "emptyDescription": "Nothing matches “{{query}}”."
+ },
+ "loading": "Loading…"
+ },
"team-sidebar": {
"membersHeading": "Members",
"noMembers": "No members yet — ask the leader to spawn one with AgentCreate.",
diff --git a/examples/web_ui/frontend/src/i18n/locales/zh.json b/examples/web_ui/frontend/src/i18n/locales/zh.json
index dcb3df2b0..d486e71ac 100644
--- a/examples/web_ui/frontend/src/i18n/locales/zh.json
+++ b/examples/web_ui/frontend/src/i18n/locales/zh.json
@@ -346,6 +346,50 @@
"completed": "已完成",
"blockedBy": "依赖"
},
+ "panel": {
+ "plan": {
+ "title": "计划",
+ "completed": "已完成:{{count}}",
+ "total": "总计:{{count}}",
+ "emptyTitle": "暂无任务",
+ "emptyDescription": "智能体规划的任务会显示在这里。"
+ },
+ "mcp": {
+ "title": "MCP",
+ "description": "工作区中配置的 MCP 服务器。",
+ "searchPlaceholder": "在工作区中搜索 MCP",
+ "add": "添加 MCP",
+ "tools": "{{count}} 个工具",
+ "emptyTitle": "暂无 MCP 服务器",
+ "emptyDescription": "添加 MCP 服务器为工作区配备工具。"
+ },
+ "skill": {
+ "title": "技能",
+ "description": "工作区中配置的技能。",
+ "searchPlaceholder": "在工作区中搜索技能",
+ "add": "添加技能",
+ "emptyTitle": "暂无技能",
+ "emptyDescription": "添加技能为工作区配备能力。"
+ },
+ "permission": {
+ "title": "权限",
+ "description": "本会话应用的权限。",
+ "mode": "模式:{{mode}}",
+ "workingDirectories": "工作目录",
+ "noWorkingDirectories": "暂无工作目录。",
+ "allow": "允许",
+ "deny": "拒绝",
+ "ask": "询问",
+ "anyInvocation": "任意调用",
+ "emptyTitle": "暂无规则",
+ "emptyDescription": "允许 / 拒绝 / 询问规则会在添加后显示在这里。"
+ },
+ "search": {
+ "emptyTitle": "无结果",
+ "emptyDescription": "没有匹配 “{{query}}” 的结果。"
+ },
+ "loading": "加载中…"
+ },
"team-sidebar": {
"membersHeading": "成员",
"noMembers": "还没有成员——让队长用 AgentCreate 添加一个。",
diff --git a/examples/web_ui/frontend/src/pages/chat/ChatViewport.tsx b/examples/web_ui/frontend/src/pages/chat/ChatViewport.tsx
index e028c8e56..aeb043e53 100644
--- a/examples/web_ui/frontend/src/pages/chat/ChatViewport.tsx
+++ b/examples/web_ui/frontend/src/pages/chat/ChatViewport.tsx
@@ -1,23 +1,41 @@
+import type { PermissionContext } from '@agentscope-ai/agentscope/permission';
import type { TaskContext } from '@agentscope-ai/agentscope/state';
-import { Toolbox } from 'lucide-react';
+import { BookText, ChevronDown, ListTodo, PanelRight, ShieldCheck } from 'lucide-react';
import { useCallback, useEffect, useMemo, useState } from 'react';
import type { ChatModelConfig, TTSModelConfig } from '@/api';
import { sessionApi } from '@/api';
+import MCPSvg from '@/assets/images/mcp.svg?react';
import { ChatContent } from '@/components/chat/ChatContent.tsx';
import { SubagentHitlCard } from '@/components/chat/SubagentHitlCard';
-import { TaskPanel } from '@/components/chat/TaskPanel';
import { CreateCredentialDialog } from '@/components/dialog/CreateCredentialDialog';
-import { WorkspaceDrawer } from '@/components/drawer/WorkspaceDrawer.tsx';
+import { McpPanel } from '@/components/panel/McpPanel';
+import { PanelDock, type PanelDescriptor, type PanelKey } from '@/components/panel/PanelDock.tsx';
+import { PermissionPanel } from '@/components/panel/PermissionPanel';
+import { SkillPanel } from '@/components/panel/SkillPanel';
+import { TaskPanel } from '@/components/panel/TaskPanel';
import { ModelParametersPopover } from '@/components/popover/ModelParametersPopover';
import { LlmSelect } from '@/components/select/LlmSelect';
import { PermissionModeSelect } from '@/components/select/PermissionModeSelect.tsx';
+import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
+import {
+ DropdownMenu,
+ DropdownMenuCheckboxItem,
+ DropdownMenuContent,
+ DropdownMenuTrigger,
+} from '@/components/ui/dropdown-menu';
+import {
+ ResizableHandle,
+ ResizablePanel,
+ ResizablePanelGroup,
+} from '@/components/ui/resizable.tsx';
import { SidebarTrigger } from '@/components/ui/sidebar';
import { useAvailableModels } from '@/hooks/useAvailableModels';
import { useMessages } from '@/hooks/useMessages';
import { useSessions } from '@/hooks/useSessions';
import { useWorkspace } from '@/hooks/useWorkspace.ts';
+import { useTranslation } from '@/i18n/useI18n';
interface ChatViewportProps {
/**
@@ -40,6 +58,40 @@ interface ChatViewportProps {
onTeamUpdated?: () => void;
}
+/** Maximum number of panels stacked in a single dock column. */
+const MAX_PANELS_PER_COLUMN = 2;
+
+/**
+ * Insert a panel into the dock layout. Scans columns left to right and
+ * appends to the first one with spare room; if every column is full a
+ * new rightmost column is created. No-op when the panel is already
+ * open.
+ *
+ * @param layout - The current column/panel arrangement.
+ * @param key - The panel to open.
+ * @returns A new layout array (the input is never mutated).
+ */
+function openPanelInLayout(layout: PanelKey[][], key: PanelKey): PanelKey[][] {
+ if (layout.some((column) => column.includes(key))) return layout;
+ const targetIndex = layout.findIndex((column) => column.length < MAX_PANELS_PER_COLUMN);
+ if (targetIndex === -1) return [...layout, [key]];
+ return layout.map((column, index) => (index === targetIndex ? [...column, key] : column));
+}
+
+/**
+ * Remove a panel from the dock layout, dropping its column entirely if
+ * it becomes empty.
+ *
+ * @param layout - The current column/panel arrangement.
+ * @param key - The panel to close.
+ * @returns A new layout array (the input is never mutated).
+ */
+function closePanelInLayout(layout: PanelKey[][], key: PanelKey): PanelKey[][] {
+ return layout
+ .map((column) => column.filter((panelKey) => panelKey !== key))
+ .filter((column) => column.length > 0);
+}
+
/**
* The right-hand main panel of the chat page — every UI element that
* operates on a single `(agentId, sessionId)` pair lives here:
@@ -61,6 +113,7 @@ interface ChatViewportProps {
* @returns The right-side main JSX of the chat page.
*/
export function ChatViewport({ agentId, sessionId, onTeamUpdated }: ChatViewportProps) {
+ const { t } = useTranslation();
const { sessions, refetch: refetchSessions } = useSessions(agentId);
const { groups } = useAvailableModels();
@@ -83,12 +136,18 @@ export function ChatViewport({ agentId, sessionId, onTeamUpdated }: ChatViewport
const [credentialOpen, setCredentialOpen] = useState(false);
const [credentialRefetchTrigger, setCredentialRefetchTrigger] = useState(0);
const [tasksContext, setTasksContext] = useState<TaskContext | null>(null);
+ const [permissionContext, setPermissionContext] = useState<PermissionContext | null>(null);
+ // Dock layout: columns laid out left→right, each holding up to 2
+ // panels stacked top→bottom. Open order determines placement.
+ const [panelLayout, setPanelLayout] = useState<PanelKey[][]>([]);
const handleStateUpdated = useCallback((value: Record<string, unknown>) => {
if (value.tasks_context) {
setTasksContext(value.tasks_context as TaskContext);
}
- // TODO: handle permission_context updates when permission UI is built
+ if (value.permission_context) {
+ setPermissionContext(value.permission_context as PermissionContext);
+ }
}, []);
const { msgs, streaming, send, onUserConfirm, onSubagentConfirm, subagentHitl } = useMessages(
@@ -110,6 +169,89 @@ export function ChatViewport({ agentId, sessionId, onTeamUpdated }: ChatViewport
removeSkill,
} = useWorkspace(agentId, sessionId);
+ // Toggle a panel open/closed from the top-bar buttons.
+ const togglePanel = useCallback((key: PanelKey) => {
+ setPanelLayout((layout) =>
+ layout.some((column) => column.includes(key))
+ ? closePanelInLayout(layout, key)
+ : openPanelInLayout(layout, key),
+ );
+ }, []);
+
+ // Close a panel (driven by the panel's own close button).
+ const closePanel = useCallback((key: PanelKey) => {
+ setPanelLayout((layout) => closePanelInLayout(layout, key));
+ }, []);
+
+ const isPanelOpen = useCallback(
+ (key: PanelKey) => panelLayout.some((column) => column.includes(key)),
+ [panelLayout],
+ );
+
+ // Build the panel descriptors with live data. Rebuilt on every
+ // data change so the dock always renders the latest state — the
+ // dock itself stays free of any data dependency.
+ const panels = useMemo<Record<PanelKey, PanelDescriptor>>(
+ () => ({
+ plan: {
+ title: t('panel.plan.title'),
+ icon: <ListTodo className="size-4" />,
+ content: <TaskPanel tasksContext={tasksContext} />,
+ },
+ mcp: {
+ title: 'MCP',
+ icon: <MCPSvg className="size-4" />,
+ content: (
+ <McpPanel
+ mcps={mcps}
+ loading={mcpsLoading}
+ onAdd={addMcps}
+ onRemove={removeMcp}
+ />
+ ),
+ },
+ skill: {
+ title: t('panel.skill.title'),
+ icon: <BookText className="size-4" />,
+ content: (
+ <SkillPanel
+ skills={skills}
+ loading={skillsLoading}
+ onAdd={addSkill}
+ onRemove={removeSkill}
+ />
+ ),
+ },
+ permission: {
+ title: (
+ <span className="flex items-center gap-x-2">
+ {t('panel.permission.title')}
+ {permissionContext?.mode ? (
+ <Badge variant="outline" className="capitalize">
+ {t('panel.permission.mode', { mode: permissionContext.mode })}
+ </Badge>
+ ) : null}
+ </span>
+ ),
+ icon: <ShieldCheck className="size-4" />,
+ content: <PermissionPanel permissionContext={permissionContext} />,
+ },
+ }),
+ [
+ t,
+ tasksContext,
+ mcps,
+ mcpsLoading,
+ addMcps,
+ removeMcp,
+ skills,
+ skillsLoading,
+ addSkill,
+ removeSkill,
+ permissionContext,
+ ],
+ );
+
const view = sessions.find((v) => v.session.id === sessionId) ?? null;
// ChatViewport keeps its own `useSessions(agentId)` instance (the
@@ -191,6 +333,21 @@ export function ChatViewport({ agentId, sessionId, onTeamUpdated }: ChatViewport
setTasksContext(tc ?? null);
}, [view]);
+ // Sync permissionContext from the session snapshot, mirroring the
+ // tasksContext approach above. Real-time updates arrive via the
+ // state_updated event → handleStateUpdated. Clearing to null when
+ // the session is gone avoids leaking stale rules across sessions.
+ useEffect(() => {
+ if (!view) {
+ setPermissionContext(null);
+ return;
+ }
+ const pc = (view.session.state as Record<string, unknown>)?.permission_context as
+ | PermissionContext
+ | undefined;
+ setPermissionContext(pc ?? null);
+ }, [view]);
+
// Sync selectedModel + selectedFallbackModel from the session
// record. If the session has no model configured yet, auto-pick
// the first available one and persist it back so subsequent
@@ -302,133 +459,173 @@ export function ChatViewport({ agentId, sessionId, onTeamUpdated }: ChatViewport
return (
<>
<main className="flex size-full">
- <div className="flex flex-col flex-1 min-h-0 p-2">
- <div className="flex flex-row gap-x-2 justify-between">
- <div id="tour-llm-select" className="flex flex-row items-center gap-x-1">
- <SidebarTrigger className="md:hidden" />
- <LlmSelect
- value={selectedModel}
- onChange={handleLlmChange}
- onAddCredential={() => setCredentialOpen(true)}
- refetchTrigger={credentialRefetchTrigger}
- />
- <ModelParametersPopover
- selectedModel={selectedModel}
- modelCard={selectedModelCard}
- onChange={handleParametersChange}
- selectedFallbackModel={selectedFallbackModel}
- onFallbackChange={handleFallbackChange}
- selectedTTSModel={selectedTTSModel}
- onTTSChange={handleTTSChange}
- />
+ <ResizablePanelGroup orientation="horizontal">
+ <ResizablePanel className="flex flex-1" minSize="24rem">
+ <div className="flex flex-col flex-1 min-h-0 min-w-0 overflow-x-hidden p-2">
+ <div className="flex flex-row gap-x-2 justify-between">
+ <div
+ id="tour-llm-select"
+ className="flex flex-row items-center gap-x-1"
+ >
+ <SidebarTrigger className="md:hidden" />
+ <LlmSelect
+ value={selectedModel}
+ onChange={handleLlmChange}
+ onAddCredential={() => setCredentialOpen(true)}
+ refetchTrigger={credentialRefetchTrigger}
+ />
+ <ModelParametersPopover
+ selectedModel={selectedModel}
+ modelCard={selectedModelCard}
+ onChange={handleParametersChange}
+ selectedFallbackModel={selectedFallbackModel}
+ onFallbackChange={handleFallbackChange}
+ selectedTTSModel={selectedTTSModel}
+ onTTSChange={handleTTSChange}
+ />
+ </div>
+ <div id="tour-permission-mode" className="flex flex-row gap-x-1">
+ <PermissionModeSelect
+ value={selectedPermissionMode}
+ disabled={!sessionId}
+ onChange={handlePermissionModeChange}
+ />
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="gap-1 px-2"
+ >
+ <PanelRight />
+ <ChevronDown className="size-3 text-muted-foreground" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-auto">
+ <DropdownMenuCheckboxItem
+ checked={isPanelOpen('plan')}
+ onCheckedChange={() => togglePanel('plan')}
+ onSelect={(e) => e.preventDefault()}
+ >
+ <ListTodo />
+ {t('panel.plan.title')}
+ </DropdownMenuCheckboxItem>
+ <DropdownMenuCheckboxItem
+ checked={isPanelOpen('mcp')}
+ onCheckedChange={() => togglePanel('mcp')}
+ onSelect={(e) => e.preventDefault()}
+ >
+ <MCPSvg className="size-4" />
+ MCP
+ </DropdownMenuCheckboxItem>
+ <DropdownMenuCheckboxItem
+ checked={isPanelOpen('skill')}
+ onCheckedChange={() => togglePanel('skill')}
+ onSelect={(e) => e.preventDefault()}
+ >
+ <BookText />
+ {t('panel.skill.title')}
+ </DropdownMenuCheckboxItem>
+ <DropdownMenuCheckboxItem
+ checked={isPanelOpen('permission')}
+ onCheckedChange={() => togglePanel('permission')}
+ onSelect={(e) => e.preventDefault()}
+ >
+ <ShieldCheck />
+ {t('panel.permission.title')}
+ </DropdownMenuCheckboxItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ </div>
+ <div className="flex flex-1 justify-center min-h-0 overflow-hidden relative [--chat-content-w:48rem]">
+ <ChatContent
+ className={'max-w-[var(--chat-content-w)] w-full'}
+ msgs={msgs}
+ sending={streaming}
+ disabled={selectedModel === null}
+ onSend={send}
+ onUserConfirm={onUserConfirm}
+ footerSlot={
+ subagentHitl.length > 0 ? (
+ <div className="space-y-2 pb-2">
+ {subagentHitl.map((entry) => (
+ <SubagentHitlCard
+ key={`${entry.worker_session_id}:${entry.reply_id}`}
+ entry={entry}
+ onConfirm={(toolCall, confirm, rules) =>
+ onSubagentConfirm(
+ entry,
+ toolCall,
+ confirm,
+ rules,
+ )
+ }
+ />
+ ))}
+ </div>
+ ) : null
+ }
+ allowedInputTypes={(
+ selectedModelCard?.input_types ?? []
+ ).filter(
+ (t) =>
+ /^(image|video|audio|text)\/.+/.test(t) ||
+ t === 'application/pdf' ||
+ t.startsWith('application/vnd.') ||
+ t.startsWith('application/msword') ||
+ t.startsWith('application/vnd.openxmlformats'),
+ )}
+ fileProcessor={async (file) => {
+ const filePath = (file as File & { path?: string }).path;
+ if (filePath) {
+ return {
+ id: crypto.randomUUID(),
+ type: 'data' as const,
+ source: {
+ type: 'url' as const,
+ url: `file://${filePath}`,
+ media_type:
+ file.type || 'application/octet-stream',
+ },
+ name: file.name,
+ };
+ }
+ if (file.type === 'text/plain') {
+ const text = await file.text();
+ return {
+ id: crypto.randomUUID(),
+ type: 'text' as const,
+ text: `[File: ${file.name}]\n${text}`,
+ };
+ }
+ const buffer = await file.arrayBuffer();
+ const bytes = new Uint8Array(buffer);
+ let binary = '';
+ for (let i = 0; i < bytes.byteLength; i++) {
+ binary += String.fromCharCode(bytes[i]);
+ }
+ const base64 = btoa(binary);
+ return {
+ id: crypto.randomUUID(),
+ type: 'data' as const,
+ source: {
+ type: 'base64' as const,
+ media_type: file.type || 'application/octet-stream',
+ data: base64,
+ },
+ name: file.name,
+ };
+ }}
+ />
+ </div>
</div>
- <div id="tour-permission-mode" className="flex flex-row gap-x-2">
- <PermissionModeSelect
- value={selectedPermissionMode}
- disabled={!sessionId}
- onChange={handlePermissionModeChange}
- />
- </div>
- </div>
- <div className="flex flex-1 justify-center min-h-0 overflow-hidden relative [--chat-content-w:48rem]">
- <TaskPanel
- className="absolute left-0 top-0 h-full max-w-[calc(50%-var(--chat-content-w)/2)]"
- tasksContext={tasksContext}
- />
- <ChatContent
- className={'max-w-[var(--chat-content-w)] w-full'}
- msgs={msgs}
- sending={streaming}
- disabled={selectedModel === null}
- onSend={send}
- onUserConfirm={onUserConfirm}
- footerSlot={
- subagentHitl.length > 0 ? (
- <div className="space-y-2 pb-2">
- {subagentHitl.map((entry) => (
- <SubagentHitlCard
- key={`${entry.worker_session_id}:${entry.reply_id}`}
- entry={entry}
- onConfirm={(toolCall, confirm, rules) =>
- onSubagentConfirm(
- entry,
- toolCall,
- confirm,
- rules,
- )
- }
- />
- ))}
- </div>
- ) : null
- }
- allowedInputTypes={(selectedModelCard?.input_types ?? []).filter(
- (t) =>
- /^(image|video|audio|text)\/.+/.test(t) ||
- t === 'application/pdf' ||
- t.startsWith('application/vnd.') ||
- t.startsWith('application/msword') ||
- t.startsWith('application/vnd.openxmlformats'),
- )}
- fileProcessor={async (file) => {
- const filePath = (file as File & { path?: string }).path;
- if (filePath) {
- return {
- id: crypto.randomUUID(),
- type: 'data' as const,
- source: {
- type: 'url' as const,
- url: `file://${filePath}`,
- media_type: file.type || 'application/octet-stream',
- },
- name: file.name,
- };
- }
- if (file.type === 'text/plain') {
- const text = await file.text();
- return {
- id: crypto.randomUUID(),
- type: 'text' as const,
- text: `[File: ${file.name}]\n${text}`,
- };
- }
- const buffer = await file.arrayBuffer();
- const bytes = new Uint8Array(buffer);
- let binary = '';
- for (let i = 0; i < bytes.byteLength; i++) {
- binary += String.fromCharCode(bytes[i]);
- }
- const base64 = btoa(binary);
- return {
- id: crypto.randomUUID(),
- type: 'data' as const,
- source: {
- type: 'base64' as const,
- media_type: file.type || 'application/octet-stream',
- data: base64,
- },
- name: file.name,
- };
- }}
- />
- </div>
- </div>
- <div className="flex flex-col h-full gap-2 p-2">
- <WorkspaceDrawer
- mcps={mcps}
- loading={mcpsLoading}
- onAdd={addMcps}
- onRemove={removeMcp}
- skills={skills}
- skillsLoading={skillsLoading}
- onAddSkill={addSkill}
- onRemoveSkill={removeSkill}
- >
- <Button size="icon-sm" variant="ghost">
- <Toolbox />
- </Button>
- </WorkspaceDrawer>
- </div>
+ </ResizablePanel>
+ {panelLayout.length > 0 && (
+ <ResizableHandle withHandle className="bg-transparent" />
+ )}
+ <PanelDock layout={panelLayout} panels={panels} onClosePanel={closePanel} />
+ </ResizablePanelGroup>
</main>
<CreateCredentialDialog
open={credentialOpen}
diff --git a/examples/web_ui/pnpm-lock.yaml b/examples/web_ui/pnpm-lock.yaml
index b67ae5d0d..bd40abaaf 100644
--- a/examples/web_ui/pnpm-lock.yaml
+++ b/examples/web_ui/pnpm-lock.yaml
@@ -58,8 +58,8 @@ importers:
frontend:
dependencies:
'@agentscope-ai/agentscope':
- specifier: ^0.0.11
- version: 0.0.11
+ specifier: ^0.0.12
+ version: 0.0.12
'@fontsource-variable/geist':
specifier: ^5.2.8
version: 5.2.8
@@ -123,6 +123,9 @@ importers:
react-markdown:
specifier: ^10.1.0
version: 10.1.0(@types/[email protected])([email protected])
+ react-resizable-panels:
+ specifier: ^4.11.2
react-router-dom:
specifier: ^7.15.1
@@ -205,8 +208,8 @@ importers:
packages:
- '@agentscope-ai/[email protected]':
- resolution: {integrity: sha512-ysPhVS/V+56Jggj+BnOCQpGQiTtvbhWQ/oCaECGT4HbYaSp/txHA4ytYxRttRowf789ummAOGplEBonfQqRkvw==}
+ '@agentscope-ai/[email protected]':
+ resolution: {integrity: sha512-yiCNx1sqtZ2X0YHY3X4+BavDxyQ2QutSlYlVLLJ9pVw3oZg1qEKcWA7HkXiNyXtEDDs/zTM4zco8hyeTCvjKWw==}
resolution: {integrity: sha512-9NhCeYjq9+3uxgdtp20LSiJXJvN0FeCtNGpJxuMFZ1Kv3cWUNb6DOhJwUvcVCzKGR66cw4njwM6hrJLqgOwbcw==}
@@ -3897,6 +3900,12 @@ packages:
'@types/react':
optional: true
+ resolution: {integrity: sha512-+kfFbDZ8mygc7g0vxOcDzCVGuwiIUOnILqPoUHo6/uP+Mmyx6HzZU+kj1aOPDlktXuobYbr6BtQekvJwHRX4Eg==}
+ peerDependencies:
+ react: ^18.0.0 || ^19.0.0
+ react-dom: ^18.0.0 || ^19.0.0
+
resolution: {integrity: sha512-AzF62gjY6U9rkMq4RfP/r2EVtQ7DMfNMjyOp/flLTCrtRylLiK4wT4pSq6O8rOXZ2eXdZYJPEYe+ifomiv+Igg==}
engines: {node: '>=20.0.0'}
@@ -4635,7 +4644,7 @@ packages:
snapshots:
- '@agentscope-ai/[email protected]':
+ '@agentscope-ai/[email protected]':
dependencies:
'@cfworker/json-schema': 4.1.1
'@modelcontextprotocol/sdk': 1.29.0(@cfworker/[email protected])([email protected])
@@ -8512,6 +8521,11 @@ snapshots:
optionalDependencies:
'@types/react': 19.2.14
+ dependencies:
+ react: 19.2.6
+ react-dom: 19.2.6([email protected])
+
dependencies:
react: 19.2.6
diff --git a/src/agentscope/app/middleware/_state_change_middleware.py b/src/agentscope/app/middleware/_state_change_middleware.py
index c588c7105..372244e11 100644
--- a/src/agentscope/app/middleware/_state_change_middleware.py
+++ b/src/agentscope/app/middleware/_state_change_middleware.py
@@ -6,8 +6,12 @@ event stream.
Two kinds of change are detected:
- **State change** — ``tasks_context`` or ``permission_context``
- modified during the tool call (detected via hash comparison).
- Pushes ``CustomEvent(name="state_updated", value={...})``.
+ modified (detected via hash comparison). Checked both around each
+ tool call (``on_acting``, for incremental updates during a turn)
+ and around the whole reply (``on_reply``, to catch changes made
+ outside the tool-execution window — e.g. permission rules added
+ while handling a user confirmation). Pushes
+ ``CustomEvent(name="state_updated", value={...})``.
- **Team change** — the tool that just ran is one of the team tools
(``TeamCreate``, ``AgentCreate``, ``TeamDelete``). These tools
directly mutate storage (``TeamRecord``, ``SessionRecord.team_id``),
@@ -82,6 +86,68 @@ class StateChangeMiddleware(MiddlewareBase): # pylint: disable=abstract-method
)
return hashlib.md5(raw.encode()).hexdigest()
+ async def _publish_state(self, agent: Any) -> None:
+ """Push a ``state_updated`` event with the current tracked state.
+
+ Args:
+ agent: The agent instance whose state to publish.
+ """
+ event = CustomEvent(
+ name="state_updated",
+ value={
+ "tasks_context": agent.state.tasks_context.model_dump(
+ mode="json",
+ ),
+ "permission_context": (
+ agent.state.permission_context.model_dump(
+ mode="json",
+ )
+ ),
+ },
+ )
+ await publish_session_event(
+ self._bus,
+ self._session_id,
+ event.model_dump(mode="json"),
+ )
+
+ async def on_reply(
+ self,
+ agent: Any,
+ input_kwargs: dict,
+ next_handler: Callable[..., AsyncGenerator],
+ ) -> AsyncGenerator:
+ """Wrap the whole reply turn to catch state changes that happen
+ **outside** the ``on_acting`` tool-execution window.
+
+ Permission rules added while handling a
+ ``UserConfirmResultEvent`` (the user's "always allow" choice)
+ mutate ``permission_context`` in ``_handle_incoming_event`` —
+ which runs at the *start* of the reply turn, before the
+ confirmed tool's ``on_acting`` snapshot is taken. ``on_acting``
+ therefore sees no diff (the rule is already present in both its
+ before- and after-hash) and never pushes. Snapshotting around
+ the entire reply closes that gap.
+
+ Args:
+ agent: The executing agent.
+ input_kwargs (`dict`):
+ The reply inputs (new message(s) or a resumption event).
+ next_handler (`Callable[..., AsyncGenerator]`):
+ The downstream middleware or core reply logic.
+
+ Yields:
+ ``AgentEvent | Msg`` — unchanged from downstream.
+ """
+ hash_before = self._state_hash(agent)
+
+ async for item in next_handler(**input_kwargs):
+ yield item
+
+ hash_after = self._state_hash(agent)
+ if hash_before != hash_after:
+ await self._publish_state(agent)
+
async def on_acting(
self,
agent: Any,
@@ -112,24 +178,7 @@ class StateChangeMiddleware(MiddlewareBase): # pylint: disable=abstract-method
# Check 1: state fields changed?
hash_after = self._state_hash(agent)
if hash_before != hash_after:
- event = CustomEvent(
- name="state_updated",
- value={
- "tasks_context": agent.state.tasks_context.model_dump(
- mode="json",
- ),
- "permission_context": (
- agent.state.permission_context.model_dump(
- mode="json",
- )
- ),
- },
- )
- await publish_session_event(
- self._bus,
- self._session_id,
- event.model_dump(mode="json"),
- )
+ await self._publish_state(agent)
# Check 2: team tool ran?
if tool_name in _TEAM_TOOL_NAMES: