JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
feat(web): add team management panel and agent_teams directory access
min_gitcodec6f4534b7720
diff --git a/jiuwenclaw/channels/web/app_web.py b/jiuwenclaw/channels/web/app_web.pyindex 8c4d1e7fe6..5bdfddca04 100644--- a/jiuwenclaw/channels/web/app_web.py+++ b/jiuwenclaw/channels/web/app_web.py@@ -1,4 +1,4 @@-# Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.+# Copyright (c) Huawei Technologies Co., Ltd. 2025-2026. All rights reserved."""Serve built frontend static files with optional reverse proxy.@@ -29,9 +29,19 @@ parse_dotenv_early("jiuwenclaw-web")# --- Now safe to import jiuwenclaw modules ---from jiuwenclaw.agents.harness.common.tools.ssl_config import get_insecure_ssl_context, get_ssl_verify+from jiuwenclaw.agents.harness.team.bootstrap import configure_agent_teams_homefrom jiuwenclaw.common.utils import get_agent_root_dir, get_logs_dir, \get_root_dir, get_user_workspace_dir, is_package_installation+configure_agent_teams_home()+++def _get_agent_teams_root() -> Path:+ """Return the agent teams root after dotenv initialization."""+ from openjiuwen.agent_teams.paths import get_agent_teams_home++ return get_agent_teams_home().resolve()+def _get_package_dir() -> Path:"""Get the jiuwenclaw/channels/web package directory."""@@ -141,6 +151,7 @@ class _SpaStaticHandler(SimpleHTTPRequestHandler):ws_disable_compress = Falseproject_root = get_user_workspace_dir()workspace_root = get_agent_root_dir()+ agent_teams_root = _get_agent_teams_root()logs_root = get_logs_dir()auto_harness_root = project_root / "auto-harness"logger = logging.getLogger(__name__)@@ -500,10 +511,13 @@ class _SpaStaticHandler(SimpleHTTPRequestHandler):target_resolved = target.resolve()try:in_workspace = os.path.commonpath([str(cls.workspace_root), str(target_resolved)]) == str(cls.workspace_root)+ in_agent_teams = (+ os.path.commonpath([str(cls.agent_teams_root), str(target_resolved)]) == str(cls.agent_teams_root)+ )in_logs = os.path.commonpath([str(cls.logs_root), str(target_resolved)]) == str(cls.logs_root)in_auto_harness = \os.path.commonpath([str(cls.auto_harness_root), str(target_resolved)]) == str(cls.auto_harness_root)- return in_workspace or in_logs or in_auto_harness+ return in_workspace or in_agent_teams or in_logs or in_auto_harnessexcept ValueError:return False@@ -947,6 +961,7 @@ def main() -> None:project_root = default_project_rootworkspace_root = (project_root / "agent").resolve()+ agent_teams_root = _get_agent_teams_root()logs_root = get_logs_dir().resolve()logger = _setup_logger(logs_root, args.log_level)@@ -958,6 +973,7 @@ def main() -> None:_ConfiguredHandler.ws_disable_compress = args.ws_disable_compress_ConfiguredHandler.project_root = project_root_ConfiguredHandler.workspace_root = workspace_root+ _ConfiguredHandler.agent_teams_root = agent_teams_root_ConfiguredHandler.logs_root = logs_root_ConfiguredHandler.logger = loggerhandler = partial(_ConfiguredHandler, directory=str(dist_dir))@@ -968,7 +984,7 @@ def main() -> None:logger.info("[jiuwenclaw-web] /api -> %s", api_target)logger.info("[jiuwenclaw-web] /ws -> %s", ws_target)logger.info("[jiuwenclaw-web] ws disable compress: %s", args.ws_disable_compress)- logger.info("[jiuwenclaw-web] /file-api roots -> %s, %s", workspace_root, logs_root)+ logger.info("[jiuwenclaw-web] /file-api roots -> %s, %s, %s", workspace_root, agent_teams_root, logs_root)try:server.serve_forever()except KeyboardInterrupt:diff --git a/jiuwenclaw/channels/web/frontend/src/App.tsx b/jiuwenclaw/channels/web/frontend/src/App.tsxindex 99ac7afecc..ed1e3da564 100644--- a/jiuwenclaw/channels/web/frontend/src/App.tsx+++ b/jiuwenclaw/channels/web/frontend/src/App.tsx@@ -9,6 +9,7 @@ import { ChatPanel } from './components/ChatPanel';import { SessionSidebar } from './components/SessionSidebar';import { SkillPanel } from './components/SkillPanel';import { AgentPanel } from './components/AgentPanel/index';+import { TeamPanel } from './components/TeamPanel';import { SessionsPanel } from './components/SessionsPanel';import { HeartbeatPanel } from './components/HeartbeatPanel';import CronPanel from './components/CronPanel';@@ -41,7 +42,7 @@ import { useTranslation } from 'react-i18next';import i18n from './i18n';import './App.css';-type MainNavKey = 'chat' | 'skills' | 'agents' | 'sessions' | 'heartbeat' | 'cron' | 'channels' | 'extensions' | 'configpanel' | 'logspanel' | 'browserpanel' | 'updatepanel';+type MainNavKey = 'chat' | 'skills' | 'agents' | 'teams' | 'sessions' | 'heartbeat' | 'cron' | 'channels' | 'extensions' | 'configpanel' | 'logspanel' | 'browserpanel' | 'updatepanel';// 错误边界组件interface ErrorBoundaryState {@@ -1089,9 +1090,23 @@ function AppContent() {]);const handleRestoreSession = useCallback(- (targetSessionId: string, targetMode?: string) => {+ async (targetSessionId: string, targetMode?: string) => {if (!targetSessionId.startsWith('sess_')) return;+ const resolvedMode = targetMode ?? mode;+ if (resolvedMode === 'team' && sessionId && sessionId !== targetSessionId) {+ try {+ await request('session.switch', {+ session_id: targetSessionId,+ mode: 'team',+ });+ } catch (error) {+ console.error('Failed to switch team session:', error);+ window.alert(t('sessions.errors.switchSession'));+ return;+ }+ }+disposeInFlightHistoryHandles();setHistoryPagerMeta(null);setHistoryLoadingMore(false);@@ -1106,8 +1121,8 @@ function AppContent() {setSessionId(targetSessionId);setCurrentSession(null);storeSessionId(targetSessionId);- if (targetMode) {- setMode(targetMode as AgentMode);+ if (resolvedMode) {+ setMode(resolvedMode as AgentMode);}setActiveNav('chat');// 历史加载只由下方 useEffect 发起一次。若 sessionId 与当前相同,须 bump key 才会重跑 effect,@@ -1120,7 +1135,10 @@ function AppContent() {clearSubtasks,clearTodos,disposeInFlightHistoryHandles,+ mode,+ request,resetHarnessStore,+ sessionId,setActiveNav,setCurrentSession,setHistoryLoadingMore,@@ -1130,6 +1148,7 @@ function AppContent() {setProcessing,setSessionId,setThinking,+ t,]);@@ -1223,14 +1242,12 @@ function AppContent() {/></div>- {/* Status Bar - 只在非集群模式下显示 */}- {mode !== 'team' && (- <StatusBar- onPause={handlePause}- onCancel={handleCancel}- onResume={handleResume}- />- )}+ <StatusBar+ onPause={handlePause}+ onCancel={mode === 'team' ? undefined : handleCancel}+ onResume={mode === 'team' ? undefined : handleResume}+ teamMode={mode === 'team'}+ /></div>{/* Tool Panel */}@@ -1243,6 +1260,11 @@ function AppContent() {<AgentPanel sessionId={sessionId} /></div>)}+ {activeNav === 'teams' && (+ <div className="app-section">+ <TeamPanel />+ </div>+ )}{activeNav === 'sessions' && (<div className="app-section"><SessionsPaneldiff --git a/jiuwenclaw/channels/web/frontend/src/components/ChatPanel/InputArea.tsx b/jiuwenclaw/channels/web/frontend/src/components/ChatPanel/InputArea.tsxindex ea08483456..83a4b5d63b 100644--- a/jiuwenclaw/channels/web/frontend/src/components/ChatPanel/InputArea.tsx+++ b/jiuwenclaw/channels/web/frontend/src/components/ChatPanel/InputArea.tsx@@ -323,7 +323,9 @@ export function InputArea({isListening? t('chat.placeholderVoice'): isTeamMode- ? isInterruptible+ ? isPaused+ ? t('chat.teamPauseHint')+ : isInterruptible? t('chat.placeholderTeamModeProcessing'): t('chat.placeholderTeamMode'): isAutoHarnessModediff --git a/jiuwenclaw/channels/web/frontend/src/components/SessionSidebar/index.tsx b/jiuwenclaw/channels/web/frontend/src/components/SessionSidebar/index.tsxindex a93abb2943..f25b05b360 100644--- a/jiuwenclaw/channels/web/frontend/src/components/SessionSidebar/index.tsx+++ b/jiuwenclaw/channels/web/frontend/src/components/SessionSidebar/index.tsx@@ -9,7 +9,7 @@ import { FEATURE_APP_UPDATER_UI } from '../../featureFlags';import { OffloadFilesWidget } from './OffloadFilesWidget';import './SessionSidebar.css';-type MainNavKey = 'chat' | 'skills' | 'agents' | 'sessions' | 'heartbeat' | 'cron' | 'channels' | 'extensions' | 'configpanel' | 'logspanel' | 'browserpanel' | 'updatepanel';+type MainNavKey = 'chat' | 'skills' | 'agents' | 'teams' | 'sessions' | 'heartbeat' | 'cron' | 'channels' | 'extensions' | 'configpanel' | 'logspanel' | 'browserpanel' | 'updatepanel';interface SessionSidebarProps {activeNav: MainNavKey;@@ -64,6 +64,15 @@ export function SessionSidebar({</svg>{t('nav.sessions')}</button>+ <button+ onClick={() => onNavigate('teams')}+ className={`nav-item w-full ${activeNav === 'teams' ? 'active' : ''}`}+ >+ <svg className="w-4 h-4 nav-item__icon" fill="none" stroke="currentColor" viewBox="0 0 24 24" strokeWidth={1.5}>+ <path strokeLinecap="round" strokeLinejoin="round" d="M18 18.72a8.96 8.96 0 01-12 0m12 0a3.75 3.75 0 00-6 0m6 0A8.96 8.96 0 0012 15.75a8.96 8.96 0 00-6 2.97m12 0A9 9 0 1012 21a8.96 8.96 0 006-2.28zM15 9.75a3 3 0 11-6 0 3 3 0 016 0zm6 3a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0zm-13.5 0a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0z" />+ </svg>+ {t('nav.teams')}+ </button><buttononClick={() => onNavigate('heartbeat')}className={`nav-item w-full ${activeNav === 'heartbeat' ? 'active' : ''}`}diff --git a/jiuwenclaw/channels/web/frontend/src/components/SessionsPanel/index.tsx b/jiuwenclaw/channels/web/frontend/src/components/SessionsPanel/index.tsxindex dd74b23f3a..24d6be88c0 100644--- a/jiuwenclaw/channels/web/frontend/src/components/SessionsPanel/index.tsx+++ b/jiuwenclaw/channels/web/frontend/src/components/SessionsPanel/index.tsx@@ -160,6 +160,7 @@ interface SessionItem {title?: string;channel_id?: string;user_id?: string;+ team_name?: string;last_message_at?: number;created_at?: number;message_count?: number;@@ -184,6 +185,7 @@ function toSessionItems(raw: unknown[]): SessionItem[] {title: typeof rec.title === 'string' ? rec.title : undefined,channel_id: typeof rec.channel_id === 'string' ? rec.channel_id : undefined,user_id: typeof rec.user_id === 'string' ? rec.user_id : undefined,+ team_name: typeof rec.team_name === 'string' ? rec.team_name : undefined,last_message_at: typeof rec.last_message_at === 'number' ? rec.last_message_at : undefined,created_at: typeof rec.created_at === 'number' ? rec.created_at : undefined,message_count: typeof rec.message_count === 'number' ? rec.message_count : undefined,@@ -503,6 +505,11 @@ export function SessionsPanel({title={session.title || parseSessionDisplayLabel(session.session_id, t)}><span className="truncate block">{session.title || parseSessionDisplayLabel(session.session_id, t)}</span>+ {session.mode === 'team' && session.team_name ? (+ <span className="mt-1 block truncate text-[11px] text-text-muted">+ {t('sessions.teamLabel', { team: session.team_name })}+ </span>+ ) : null}</button><buttontype="button"diff --git a/jiuwenclaw/channels/web/frontend/src/components/StatusBar/index.tsx b/jiuwenclaw/channels/web/frontend/src/components/StatusBar/index.tsxindex c5becccdf2..6b0c4c8e11 100644--- a/jiuwenclaw/channels/web/frontend/src/components/StatusBar/index.tsx+++ b/jiuwenclaw/channels/web/frontend/src/components/StatusBar/index.tsx@@ -13,9 +13,10 @@ interface StatusBarProps {onPause?: () => void;onCancel?: () => void;onResume?: () => void;+ teamMode?: boolean;}-export function StatusBar({ onPause, onCancel, onResume }: StatusBarProps) {+export function StatusBar({ onPause, onCancel, onResume, teamMode = false }: StatusBarProps) {const { t } = useTranslation();const { isProcessing, isPaused, pausedTask, interruptResult, switchingMode } = useChatStore();const showExec = (isProcessing || isPaused) && !switchingMode;@@ -25,7 +26,7 @@ export function StatusBar({ onPause, onCancel, onResume }: StatusBarProps) {return (<div className="statusbar-root"><div className="statusbar-center">- {showInterruptBarOnly ? (+ {showInterruptBarOnly && !teamMode ? (<divclassName={`pill animate-fade-in ${interruptResult!.success@@ -37,8 +38,25 @@ export function StatusBar({ onPause, onCancel, onResume }: StatusBarProps) {</div>) : (<>+ {teamMode && onPause && (+ <div className="statusbar-exec">+ {isPaused ? (+ <div className="statusbar-pill statusbar-pill--paused">+ <span className="statusbar-dot" />+ <span>{t('statusBar.paused')}</span>+ </div>+ ) : (+ <button+ onClick={onPause}+ className="statusbar-action-btn statusbar-action-btn--pause"+ >+ {t('statusBar.pause')}+ </button>+ )}+ </div>+ )}{/* 执行状态:左侧取消,中间状态,右侧暂停/恢复 */}- {showExec && (+ {!teamMode && showExec && (<div className="statusbar-exec">{onCancel && (<buttondiff --git a/jiuwenclaw/channels/web/frontend/src/components/TeamPanel/index.tsx b/jiuwenclaw/channels/web/frontend/src/components/TeamPanel/index.tsxnew file mode 100644index 0000000000..4cf946350a--- /dev/null+++ b/jiuwenclaw/channels/web/frontend/src/components/TeamPanel/index.tsx@@ -0,0 +1,465 @@+import { useCallback, useEffect, useState } from 'react';+import { useTranslation } from 'react-i18next';+import { FileViewer } from '../AgentPanel/FileViewer';+import { webRequest } from '../../services/webClient';+import { containsIgnoredDirectory } from '../../features/fileTreeFilters';++interface SessionListResponse {+ sessions?: unknown[];+}++interface TeamInfo {+ name: string;+ sessionCount: number;+}++interface DirectoryItem {+ name: string;+ path: string;+ isMarkdown: boolean;+ isDirectory: boolean;+}++interface ListFilesResponse {+ files?: unknown[];+}++function normalizePath(path: string): string {+ return path.replace(/\\/g, '/').replace(/\/+/g, '/').trim();+}++function isPreviewableFile(fileName: string): boolean {+ const lowerName = fileName.toLowerCase();+ return lowerName.endsWith('.md') || lowerName.endsWith('.mdx') || lowerName.endsWith('.json');+}++function getParentPath(filePath: string): string {+ const normalizedPath = normalizePath(filePath);+ if (!normalizedPath.includes('/')) return '';+ return normalizedPath.slice(0, normalizedPath.lastIndexOf('/'));+}++function isHiddenTeamItem(item: DirectoryItem): boolean {+ if (item.name === '.team' && item.isDirectory) return false;+ if (item.name.startsWith('.')) return true;+ if (containsIgnoredDirectory(item.path)) return true;++ const lowerName = item.name.toLowerCase();+ const parentPath = getParentPath(item.path);+ return lowerName === 'skills_state.json' && parentPath.endsWith('/skills');+}++function toDirectoryItems(raw: unknown[]): DirectoryItem[] {+ const rows: DirectoryItem[] = [];+ for (const item of raw) {+ if (!item || typeof item !== 'object') continue;+ const rec = item as Record<string, unknown>;+ const name = rec.name;+ const path = rec.path;+ const isMarkdown = rec.isMarkdown;+ const isDirectory = rec.isDirectory;+ if (+ typeof name !== 'string' ||+ typeof path !== 'string' ||+ typeof isMarkdown !== 'boolean' ||+ typeof isDirectory !== 'boolean'+ ) {+ continue;+ }+ const row = { name, path: normalizePath(path), isMarkdown, isDirectory };+ if (isHiddenTeamItem(row)) continue;+ rows.push(row);+ }+ return rows.sort((a, b) => {+ if (a.isDirectory !== b.isDirectory) return a.isDirectory ? -1 : 1;+ return a.name.localeCompare(b.name, 'zh-Hans-CN');+ });+}++function toTeamInfos(raw: unknown[]): TeamInfo[] {+ const counts = new Map<string, number>();+ for (const item of raw) {+ if (!item || typeof item !== 'object') continue;+ const rec = item as Record<string, unknown>;+ const mode = typeof rec.mode === 'string' ? rec.mode : '';+ const teamName = typeof rec.team_name === 'string' ? rec.team_name.trim() : '';+ if (mode !== 'team' || !teamName) continue;+ counts.set(teamName, (counts.get(teamName) ?? 0) + 1);+ }+ return Array.from(counts.entries())+ .map(([name, sessionCount]) => ({ name, sessionCount }))+ .sort((a, b) => a.name.localeCompare(b.name, 'zh-Hans-CN'));+}++export function TeamPanel() {+ const { t } = useTranslation();+ const [teams, setTeams] = useState<TeamInfo[]>([]);+ const [selectedTeamName, setSelectedTeamName] = useState('');+ const [loadingTeams, setLoadingTeams] = useState(true);+ const [loadingFiles, setLoadingFiles] = useState(false);+ const [deletingTeamName, setDeletingTeamName] = useState('');+ const [error, setError] = useState<string | null>(null);+ const [dirChildren, setDirChildren] = useState<Map<string, DirectoryItem[]>>(new Map());+ const [loadingDirs, setLoadingDirs] = useState<Set<string>>(new Set());+ const [selectedFile, setSelectedFile] = useState<DirectoryItem | null>(null);+ const [expandedPaths, setExpandedPaths] = useState<Set<string>>(new Set());++ const deletingTeam = Boolean(deletingTeamName);+ const selectedRoot = selectedTeamName ? `.agent_teams/${selectedTeamName}` : '';++ const loadTeams = useCallback(async () => {+ setLoadingTeams(true);+ try {+ const payload = await webRequest<SessionListResponse>('session.list', {});+ const nextTeams = Array.isArray(payload?.sessions) ? toTeamInfos(payload.sessions) : [];+ setTeams(nextTeams);+ setError(null);+ setSelectedTeamName((current) => {+ if (current && nextTeams.some((team) => team.name === current)) {+ return current;+ }+ return nextTeams[0]?.name ?? '';+ });+ } catch (loadError) {+ console.error('Failed to load teams:', loadError);+ setTeams([]);+ setSelectedTeamName('');+ setError(t('teams.errors.loadTeams'));+ } finally {+ setLoadingTeams(false);+ }+ }, [t]);++ const loadDirectory = useCallback(async (dir: string, options?: { initial?: boolean }) => {+ const normalizedDir = normalizePath(dir);+ if (!normalizedDir) return;++ if (options?.initial) {+ setLoadingFiles(true);+ setDirChildren(new Map());+ setExpandedPaths(new Set());+ setSelectedFile(null);+ } else {+ setLoadingDirs((prev) => {+ const next = new Set(prev);+ next.add(normalizedDir);+ return next;+ });+ }+ setError(null);++ try {+ const encodedDir = encodeURIComponent(dir);+ const response = await fetch(`/file-api/list-files?dir=${encodedDir}`, { cache: 'no-store' });+ if (!response.ok) {+ const text = await response.text();+ throw new Error(`HTTP ${response.status}: ${text.substring(0, 120)}`);+ }+ const payload = (await response.json()) as ListFilesResponse;+ const rows = Array.isArray(payload?.files) ? toDirectoryItems(payload.files) : [];+ setDirChildren((prev) => {+ const next = new Map(prev);+ next.set(normalizedDir, rows);+ return next;+ });+ } catch (loadError) {+ console.error('Failed to load team directory:', loadError);+ setError(t('teams.errors.loadDirectory'));+ } finally {+ if (options?.initial) {+ setLoadingFiles(false);+ } else {+ setLoadingDirs((prev) => {+ const next = new Set(prev);+ next.delete(normalizedDir);+ return next;+ });+ }+ }+ }, [t]);++ const loadTeamFiles = useCallback(async (teamName: string) => {+ if (!teamName) {+ setDirChildren(new Map());+ setSelectedFile(null);+ setExpandedPaths(new Set());+ return;+ }+ await loadDirectory(`.agent_teams/${teamName}`, { initial: true });+ }, [loadDirectory]);++ useEffect(() => {+ void loadTeams();+ }, [loadTeams]);++ useEffect(() => {+ void loadTeamFiles(selectedTeamName);+ }, [loadTeamFiles, selectedTeamName]);++ const handleRefresh = () => {+ void loadTeams();+ if (selectedTeamName) {+ void loadTeamFiles(selectedTeamName);+ }+ };++ const deleteTeam = async (teamName: string) => {+ if (!teamName || deletingTeam) return;+ const confirmed = window.confirm(t('teams.deleteConfirm', { team: teamName }));+ if (!confirmed) return;++ setDeletingTeamName(teamName);+ try {+ await webRequest('team.delete', {+ team_name: teamName,+ mode: 'team',+ });+ if (selectedTeamName === teamName) {+ setSelectedFile(null);+ setDirChildren(new Map());+ }+ await loadTeams();+ } catch (deleteError) {+ console.error('Failed to delete team:', deleteError);+ setError(t('teams.errors.deleteTeam', { team: teamName }));+ } finally {+ setDeletingTeamName('');+ }+ };++ const toggleExpanded = (path: string) => {+ const normalizedPath = normalizePath(path);+ setExpandedPaths((prev) => {+ const next = new Set(prev);+ if (next.has(normalizedPath)) {+ next.delete(normalizedPath);+ } else {+ next.add(normalizedPath);+ }+ return next;+ });+ if (!expandedPaths.has(normalizedPath) && !dirChildren.has(normalizedPath)) {+ void loadDirectory(normalizedPath);+ }+ };++ const renderDirectoryChildren = (parentPath: string, depth: number): JSX.Element[] => {+ const children = dirChildren.get(parentPath) ?? [];+ return children.flatMap((item) => {+ const selectable = !item.isDirectory && isPreviewableFile(item.name);+ const selected = selectedFile?.path === item.path;+ if (item.isDirectory) {+ const isExpanded = expandedPaths.has(item.path);+ const isLoading = loadingDirs.has(item.path);+ const hasChildren = isLoading || !dirChildren.has(item.path) || (dirChildren.get(item.path) ?? []).length > 0;+ return [+ <div key={item.path}>+ <button+ type="button"+ onClick={() => toggleExpanded(item.path)}+ className="w-full min-h-10 flex items-center gap-2 rounded-lg px-2 py-2 text-left text-sm text-text-muted hover:bg-secondary/40 hover:text-text transition-colors"+ style={{ paddingLeft: `${depth * 16 + 12}px` }}+ title={item.path}+ >+ <span className="w-4 h-4 flex items-center justify-center text-text-muted/80">+ {hasChildren ? (+ <svg+ className={`w-3 h-3 transition-transform ${isExpanded ? 'rotate-90' : ''}`}+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2"+ >+ <path strokeLinecap="round" strokeLinejoin="round" d="M9 6l6 6-6 6" />+ </svg>+ ) : null}+ </span>+ <svg className="w-4 h-4 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8">+ <path strokeLinecap="round" strokeLinejoin="round" d="M3.75 6.75h4.5l1.5 2.25h10.5v8.25A2.25 2.25 0 0118 19.5H6A2.25 2.25 0 013.75 17.25V6.75z" />+ </svg>+ <span className="flex-1 min-w-0 truncate">{item.name}</span>+ {isLoading ? (+ <span className="w-3 h-3 rounded-full border-2 border-border border-t-accent animate-spin" />+ ) : null}+ </button>+ {isExpanded ? renderDirectoryChildren(item.path, depth + 1) : null}+ </div>,+ ];+ }+ return [+ <button+ key={item.path}+ type="button"+ disabled={!selectable}+ onClick={() => {+ if (selectable) setSelectedFile(item);+ }}+ className={`w-full min-h-10 flex items-center gap-2 rounded-lg px-2 py-2 text-left text-sm transition-colors ${+ selected+ ? 'border border-[var(--border-accent)] bg-accent-subtle text-text'+ : selectable+ ? 'border border-transparent text-text-muted hover:bg-secondary/40 hover:text-text'+ : 'border border-transparent text-text-muted/70 cursor-default'+ }`}+ style={{ paddingLeft: `${depth * 16 + 12}px` }}+ title={item.path}+ >+ <span className="w-4 h-4 flex items-center justify-center" />+ <svg className="w-4 h-4 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8">+ {item.isMarkdown ? (+ <path strokeLinecap="round" strokeLinejoin="round" d="M6.75 3.75h7.5l4.5 4.5v12a1.5 1.5 0 01-1.5 1.5h-10.5a1.5 1.5 0 01-1.5-1.5v-15a1.5 1.5 0 011.5-1.5zM9 14.25V9.75l3 3 3-3v4.5" />+ ) : (+ <path strokeLinecap="round" strokeLinejoin="round" d="M6.75 3.75h7.5l4.5 4.5v12a1.5 1.5 0 01-1.5 1.5h-10.5a1.5 1.5 0 01-1.5-1.5v-15a1.5 1.5 0 011.5-1.5zM14.25 3.75v4.5h4.5" />+ )}+ </svg>+ <span className="flex-1 min-w-0 truncate">{item.name}</span>+ {!selectable ? (+ <span className="text-[10px] px-1.5 py-0.5 rounded border border-border bg-secondary/50 text-text-muted">+ {t('teams.notPreviewable')}+ </span>+ ) : null}+ </button>,+ ];+ });+ };++ return (+ <div className="flex-1 min-h-0">+ <div className="card w-full h-full flex flex-col">+ <div className="flex items-center justify-between gap-4 mb-4">+ <div>+ <h2 className="text-lg font-semibold">{t('teams.title')}</h2>+ <p className="text-sm text-text-muted mt-1">{t('teams.subtitle')}</p>+ </div>+ <button+ type="button"+ onClick={handleRefresh}+ disabled={loadingTeams || loadingFiles}+ className="btn !px-3 !py-1.5 disabled:opacity-50 disabled:cursor-not-allowed"+ >+ {loadingTeams || loadingFiles ? t('common.refreshing') : t('common.refresh')}+ </button>+ </div>++ {error ? (+ <div className="mb-4 rounded-md border border-danger/30 bg-danger/10 px-3 py-2 text-sm text-danger">+ {error}+ </div>+ ) : null}++ <div className="flex-1 min-h-0 grid grid-cols-[minmax(240px,1.2fr)_minmax(0,4fr)] gap-4">+ <div className="rounded-xl border border-border bg-card/70 backdrop-blur-sm overflow-hidden shadow-sm flex flex-col min-h-0">+ <div className="px-4 py-3 bg-secondary/30 border-b border-border">+ <h3 className="text-sm font-medium text-text">{t('teams.teamList')}</h3>+ <p className="text-xs text-text-muted mt-1">+ {t('teams.count', { count: teams.length })}+ </p>+ </div>+ <div className="flex-1 overflow-auto p-2 space-y-1">+ {loadingTeams ? (+ <div className="h-full flex items-center justify-center">+ <div className="w-7 h-7 rounded-full border-4 border-border border-t-accent animate-spin" />+ </div>+ ) : teams.length === 0 ? (+ <div className="h-full flex items-center justify-center text-sm text-text-muted">{t('teams.empty')}</div>+ ) : (+ teams.map((team) => (+ <div+ key={team.name}+ className={`w-full min-w-0 flex items-center gap-2 rounded-lg border px-3 py-2 text-sm transition-colors ${+ selectedTeamName === team.name+ ? 'border-[var(--border-accent)] bg-accent-subtle text-text'+ : 'border-transparent hover:bg-secondary/40 text-text-muted hover:text-text'+ }`}+ >+ <button+ type="button"+ onClick={() => setSelectedTeamName(team.name)}+ className="min-w-0 flex-1 text-left"+ title={team.name}+ >+ <span className="truncate block font-medium">{team.name}</span>+ <span className="mt-1 block text-[11px] text-text-muted">+ {t('teams.sessionCount', { count: team.sessionCount })}+ </span>+ </button>+ <button+ type="button"+ onClick={(event) => {+ event.stopPropagation();+ void deleteTeam(team.name);+ }}+ disabled={deletingTeam}+ className="shrink-0 text-xs px-2 py-1 rounded-md border border-danger/30 text-danger hover:bg-danger-subtle disabled:opacity-50 disabled:cursor-not-allowed"+ title={t('teams.deleteTeam')}+ >+ {deletingTeamName === team.name ? t('teams.deleting') : t('teams.deleteTeam')}+ </button>+ </div>+ ))+ )}+ </div>+ </div>++ <div className="rounded-xl border border-border bg-card/70 backdrop-blur-sm overflow-hidden shadow-sm grid grid-cols-[minmax(0,1fr)_minmax(0,3fr)] min-h-0">+ <div className="border-r border-border flex flex-col min-h-0">+ <div className="px-4 py-3 bg-secondary/30 border-b border-border">+ <div className="min-w-0">+ <h3 className="text-sm font-medium text-text">{t('teams.directory')}</h3>+ <p className="text-xs text-text-muted mt-1 truncate" title={selectedTeamName || t('teams.noneSelected')}>+ {selectedTeamName || t('teams.noneSelected')}+ </p>+ </div>+ </div>+ <div className="flex-1 overflow-auto p-2">+ {!selectedTeamName ? (+ <div className="h-full flex items-center justify-center text-sm text-text-muted">{t('teams.selectFirst')}</div>+ ) : loadingFiles ? (+ <div className="h-full flex items-center justify-center text-sm text-text-muted">{t('teams.loadingDirectory')}</div>+ ) : (+ <div className="space-y-1">+ <div>+ <button+ type="button"+ onClick={() => toggleExpanded(selectedRoot)}+ className="w-full min-h-10 flex items-center gap-2 rounded-lg px-2 py-2 text-left text-sm text-text-muted hover:bg-secondary/40 hover:text-text transition-colors"+ title={selectedRoot}+ >+ <span className="w-4 h-4 flex items-center justify-center text-text-muted/80">+ <svg+ className={`w-3 h-3 transition-transform ${expandedPaths.has(selectedRoot) ? 'rotate-90' : ''}`}+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ strokeWidth="2"+ >+ <path strokeLinecap="round" strokeLinejoin="round" d="M9 6l6 6-6 6" />+ </svg>+ </span>+ <svg className="w-4 h-4 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8">+ <path strokeLinecap="round" strokeLinejoin="round" d="M3.75 6.75h4.5l1.5 2.25h10.5v8.25A2.25 2.25 0 0118 19.5H6A2.25 2.25 0 013.75 17.25V6.75z" />+ </svg>+ <span className="flex-1 min-w-0 truncate">{selectedTeamName}</span>+ </button>+ {expandedPaths.has(selectedRoot) ? renderDirectoryChildren(selectedRoot, 1) : null}+ </div>+ </div>+ )}+ </div>+ </div>++ <div className="flex-1 min-h-0">+ {selectedFile ? (+ <FileViewer filePath={selectedFile.path} fileName={selectedFile.name} />+ ) : (+ <div className="h-full flex items-center justify-center text-text-muted">+ {t('teams.selectFile')}+ </div>+ )}+ </div>+ </div>+ </div>+ </div>+ </div>+ );+}diff --git a/jiuwenclaw/channels/web/frontend/src/hooks/useWebSocket.ts b/jiuwenclaw/channels/web/frontend/src/hooks/useWebSocket.tsindex 0317c5a8f9..c786197553 100644--- a/jiuwenclaw/channels/web/frontend/src/hooks/useWebSocket.ts+++ b/jiuwenclaw/channels/web/frontend/src/hooks/useWebSocket.ts@@ -332,6 +332,9 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {if (currentMode === 'auto_harness') {useHarnessStore.getState().reset();}+ if (currentMode === 'team') {+ setPaused(false);+ }try {await request('chat.send', {session_id: sessionId,@@ -385,6 +388,10 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {session_id: sessionId,intent,};+ if (useSessionStore.getState().mode === 'team' && (intent === 'pause' || intent === 'resume')) {+ params.mode = 'team';+ params.team = true;+ }if (intent === 'supplement') {params.new_input = newInput ?? '';const selectedModel = useSessionStore.getState().selectedModelName;diff --git a/jiuwenclaw/channels/web/frontend/src/i18n/locales/en.json b/jiuwenclaw/channels/web/frontend/src/i18n/locales/en.jsonindex 991f3def5a..94aa56bf4f 100644--- a/jiuwenclaw/channels/web/frontend/src/i18n/locales/en.json+++ b/jiuwenclaw/channels/web/frontend/src/i18n/locales/en.json@@ -17,6 +17,7 @@"nav": {"chat": "Chat","agent": "Agent",+ "teams": "Teams","sessions": "Sessions","heartbeat": "Heartbeat","cron": "Scheduled Tasks",@@ -44,6 +45,30 @@"statusShutdown": "Shutdown","statusError": "Error"},+ "teams": {+ "title": "Team Management",+ "subtitle": "Inspect team directories or delete teams",+ "teamList": "Teams",+ "count": "{{count}} team(s)",+ "sessionCount": "{{count}} session(s)",+ "directory": "Team Directory",+ "noneSelected": "No team selected",+ "empty": "No teams",+ "selectFirst": "Select a team first",+ "loadingDirectory": "Loading team directory...",+ "emptyDirectory": "No files in this team directory",+ "deleteTeam": "Delete team",+ "deleting": "Deleting...",+ "deleteConfirm": "Delete team {{team}}?\nThis will delete the team runtime, linked sessions, and directory.",+ "folder": "Folder",+ "notPreviewable": "Not previewable",+ "selectFile": "Select a file to view",+ "errors": {+ "loadTeams": "Failed to load teams",+ "loadDirectory": "Failed to load team directory",+ "deleteTeam": "Failed to delete team: {{team}}"+ }+ },"statusBar": {"cancel": "Cancel","pause": "Pause",@@ -95,6 +120,8 @@"newSessionDisabled": "Cannot create session while processing or recording","modeSwitchTitle": "Switch Mode","modeSwitchConfirm": "Current session has history messages. Switching mode will create a new session. Continue?",+ "teamPause": "Pause",+ "teamPauseHint": "After pausing a team, send the next message to continue","historyPager": {"loadedOfTotal": "Loaded {{loaded}} / {{total}} pages","loadingMore": "Loading...",@@ -210,6 +237,7 @@"restoreDisabledUnsupported": "Only web frontend sessions (sess_) can be restored","restoreEmpty": "This session has no restorable messages (empty or filtered). You can still chat from here.","delete": "Delete session",+ "teamLabel": "Team: {{team}}","files": "Session Files","selectFirst": "Select a session first","loadingFiles": "Loading files...",@@ -237,6 +265,7 @@"loadSessions": "Failed to load sessions","loadFiles": "Failed to load session files","deleteSession": "Failed to delete session: {{sessionId}}",+ "switchSession": "Failed to switch team session","restoreFailed": "Failed to restore session: {{sessionId}}"}},diff --git a/jiuwenclaw/channels/web/frontend/src/i18n/locales/zh.json b/jiuwenclaw/channels/web/frontend/src/i18n/locales/zh.jsonindex c4223c4911..bd77641269 100644--- a/jiuwenclaw/channels/web/frontend/src/i18n/locales/zh.json+++ b/jiuwenclaw/channels/web/frontend/src/i18n/locales/zh.json@@ -17,6 +17,7 @@"nav": {"chat": "对话","agent": "智能体",+ "teams": "团队","sessions": "会话","heartbeat": "心跳","cron": "定时任务",@@ -44,6 +45,30 @@"statusShutdown": "已关闭","statusError": "错误"},+ "teams": {+ "title": "团队管理",+ "subtitle": "查看团队目录或删除团队",+ "teamList": "团队列表",+ "count": "当前 {{count}} 个团队",+ "sessionCount": "{{count}} 个会话",+ "directory": "团队目录",+ "noneSelected": "未选择团队",+ "empty": "暂无团队",+ "selectFirst": "请先选择团队",+ "loadingDirectory": "加载团队目录中...",+ "emptyDirectory": "暂无团队目录文件",+ "deleteTeam": "删除团队",+ "deleting": "删除中...",+ "deleteConfirm": "确认删除团队 {{team}} ?\n将删除团队运行时、关联会话及目录。",+ "folder": "文件夹",+ "notPreviewable": "不可预览",+ "selectFile": "请选择一个文件查看",+ "errors": {+ "loadTeams": "团队列表加载失败",+ "loadDirectory": "团队目录加载失败",+ "deleteTeam": "删除团队失败:{{team}}"+ }+ },"statusBar": {"cancel": "取消","pause": "暂停",@@ -95,6 +120,8 @@"newSessionDisabled": "处理中或录音中不可新建","modeSwitchTitle": "切换模式","modeSwitchConfirm": "当前会话有历史消息,切换模式将新建会话。是否继续?",+ "teamPause": "暂停",+ "teamPauseHint": "团队暂停后,直接发送下一条消息即可继续","historyPager": {"loadedOfTotal": "历史已加载 {{loaded}} / {{total}} 页","loadingMore": "加载中…",@@ -210,6 +237,7 @@"restoreDisabledUnsupported": "仅支持恢复 web 前端会话(sess_)","restoreEmpty": "该会话没有可恢复的消息(为空或均被过滤)。仍可在此继续对话。","delete": "删除会话",+ "teamLabel": "团队:{{team}}","files": "会话文件","selectFirst": "请先选择会话","loadingFiles": "加载文件中...",@@ -237,6 +265,7 @@"loadSessions": "会话列表加载失败","loadFiles": "会话文件列表加载失败","deleteSession": "删除会话失败:{{sessionId}}",+ "switchSession": "切换团队会话失败","restoreFailed": "恢复会话失败:{{sessionId}}"}},diff --git a/jiuwenclaw/channels/web/frontend/vite.config.ts b/jiuwenclaw/channels/web/frontend/vite.config.tsindex eba6835f4d..ffa8b0c9ec 100644--- a/jiuwenclaw/channels/web/frontend/vite.config.ts+++ b/jiuwenclaw/channels/web/frontend/vite.config.ts@@ -164,6 +164,7 @@ function devWsTrafficLogger(): Plugin {function devFileContentApi(): Plugin {const projectRootDir = resolveProjectRootDir()const workspaceRootDir = path.resolve(projectRootDir, 'agent')+ const agentTeamsRootDir = path.resolve(projectRootDir, '.agent_teams')const webLogsRootDir = path.resolve(projectRootDir, '.logs')const autoHarnessDir = path.resolve(projectRootDir, 'auto-harness')const generateAgentFoldersScriptPath = path.resolve(__dirname, '../scripts/generate-agent-folders.js')@@ -176,11 +177,13 @@ function devFileContentApi(): Plugin {const isPathUnderAllowedRoot = (targetPath: string) => {const relativeWorkspacePath = path.relative(workspaceRootDir, targetPath)const inWorkspace = !relativeWorkspacePath.startsWith('..') && !path.isAbsolute(relativeWorkspacePath)+ const relativeAgentTeamsPath = path.relative(agentTeamsRootDir, targetPath)+ const inAgentTeams = !relativeAgentTeamsPath.startsWith('..') && !path.isAbsolute(relativeAgentTeamsPath)const relativeLogsPath = path.relative(webLogsRootDir, targetPath)const inWebLogs = !relativeLogsPath.startsWith('..') && !path.isAbsolute(relativeLogsPath)const relativeAutoHarnessPath = path.relative(autoHarnessDir, targetPath)const inAutoHarness = !relativeAutoHarnessPath.startsWith('..') && !path.isAbsolute(relativeAutoHarnessPath)- return inWorkspace || inWebLogs || inAutoHarness+ return inWorkspace || inAgentTeams || inWebLogs || inAutoHarness}return {