feat(outlook): 添加Outlook集成功能支持

添加完整的Outlook MCP集成,包括邮件和日历功能,通过AuthZ模式进行认证和权限管理,
支持邮箱连接、断开、状态检查和数据同步等功能。

fix(config): 统一配置文件路径从.nanobot到.beaver

将配置文件路径从/root/.nanobot统一更改为/root/.beaver,更新Dockerfile中的环境变量定义,
确保所有组件使用一致的配置目录结构。

feat(agent): 添加代理删除功能和助手身份提示

为代理注册表添加delete_agent方法,实现代理的动态删除功能;同时添加海狸助手身份提示,
确保AI助手在交互中保持一致的身份认知。

feat(engine): 增强引擎循环并添加意图决策快照

扩展AgentLoop类,添加intent_agent_decision参数用于意图驱动的代理决策,并在会话中记录
决策快照,便于后续分析和调试。

feat(authz): 扩展认证客户端功能

为AuthzClient添加设置权限、用户注册、后端注册和Outlook设置管理等新方法,增强系统
的认证和授权能力。
This commit is contained in:
2026-05-14 16:01:46 +08:00
parent 30ab74ffb2
commit ebfa242862
35 changed files with 3979 additions and 462 deletions

View File

@ -245,7 +245,7 @@ docker build \
当前仓库的部分技术标识仍沿用旧命名,例如:
- `nanobot web`
- `~/.nanobot/plugins/`
- `~/.beaver/plugins/`
- 本地存储中的旧 token key
这些属于兼容性和后端约定的一部分,前端展示品牌已替换为 `Boardware Genius`,但技术标识没有在这个仓库里强制迁移。

View File

@ -721,7 +721,7 @@ export default function AgentsPage() {
<Card className="border-border/70 bg-muted/20">
<CardContent className="pt-6 text-sm text-muted-foreground leading-relaxed">
{t('持久化 Sub-Agent 会在', 'Persistent sub-agents keep their own workspace under')}
<code className="mx-1">~/.nanobot/workspace/agents/&lt;id&gt;_agent</code>
<code className="mx-1">~/.beaver/workspace/agents/&lt;id&gt;_agent</code>
{t('下拥有自己的 workspace、`AGENTS.json`、`AGENTS.md`、skills 和 memory。默认委派模式是', ', plus `AGENTS.json`, `AGENTS.md`, skills, and memory. The default delegation mode is')}
<code className="mx-1">remote_a2a_only</code>
{t(',即只能向外委派到远端 A2A agent。', ', which only allows delegation to remote A2A agents.')}

View File

@ -18,18 +18,21 @@ import {
FileArchive,
FileSpreadsheet,
} from 'lucide-react';
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import {
browseWorkspace,
getWorkspaceFile,
getWorkspaceDownloadUrl,
uploadToWorkspace,
deleteWorkspacePath,
createWorkspaceDir,
getAccessToken,
} from '@/lib/api';
import type { WorkspaceItem } from '@/lib/api';
import type { WorkspaceFileContent, WorkspaceItem } from '@/lib/api';
import { Button } from '@/components/ui/button';
import { ScrollArea } from '@/components/ui/scroll-area';
import { pickAppText } from '@/lib/i18n/core';
import { type AppLocale, pickAppText } from '@/lib/i18n/core';
import { useAppI18n } from '@/lib/i18n/provider';
export default function FilesPage() {
@ -41,6 +44,9 @@ export default function FilesPage() {
const [uploadProgress, setUploadProgress] = useState(0);
const [showMkdir, setShowMkdir] = useState(false);
const [newDirName, setNewDirName] = useState('');
const [selectedFile, setSelectedFile] = useState<WorkspaceFileContent | null>(null);
const [previewLoading, setPreviewLoading] = useState(false);
const [previewError, setPreviewError] = useState<string | null>(null);
const fileInputRef = useRef<HTMLInputElement>(null);
const mkdirInputRef = useRef<HTMLInputElement>(null);
@ -50,6 +56,8 @@ export default function FilesPage() {
const data = await browseWorkspace(path);
setItems(data.items);
setCurrentPath(data.path);
setSelectedFile(null);
setPreviewError(null);
} catch {
// ignore
} finally {
@ -65,6 +73,20 @@ export default function FilesPage() {
load(path);
};
const openFile = async (item: WorkspaceItem) => {
if (item.type !== 'file') return;
setPreviewLoading(true);
setPreviewError(null);
try {
setSelectedFile(await getWorkspaceFile(item.path));
} catch (err: any) {
setPreviewError(err.message || pickAppText(locale, '加载文件失败', 'Failed to load file'));
setSelectedFile(null);
} finally {
setPreviewLoading(false);
}
};
const handleDelete = async (item: WorkspaceItem) => {
const label = item.type === 'directory'
? pickAppText(locale, '文件夹', 'folder')
@ -79,6 +101,9 @@ export default function FilesPage() {
try {
await deleteWorkspacePath(item.path);
setItems((prev) => prev.filter((i) => i.path !== item.path));
if (selectedFile?.path === item.path) {
setSelectedFile(null);
}
} catch {
// ignore
}
@ -165,7 +190,7 @@ export default function FilesPage() {
};
return (
<div className="max-w-4xl mx-auto p-6">
<div className="mx-auto max-w-7xl p-6">
{/* Header */}
<div className="flex items-center justify-between mb-4">
<h1 className="text-2xl font-bold">{pickAppText(locale, '文件管理', 'Files')}</h1>
@ -280,84 +305,191 @@ export default function FilesPage() {
</div>
)}
{/* File list */}
{loading && items.length === 0 ? (
<div className="flex items-center justify-center py-20 text-muted-foreground">
<Loader2 className="w-6 h-6 animate-spin" />
<div className="grid gap-4 lg:grid-cols-[minmax(360px,440px)_minmax(0,1fr)]">
{/* File list */}
<div className="min-h-[520px] rounded-lg border border-border bg-card">
{loading && items.length === 0 ? (
<div className="flex items-center justify-center py-20 text-muted-foreground">
<Loader2 className="w-6 h-6 animate-spin" />
</div>
) : items.length === 0 ? (
<div className="flex flex-col items-center justify-center py-20 text-muted-foreground">
<FolderOpen className="w-12 h-12 mb-4 opacity-50" />
<p className="text-lg font-medium">{pickAppText(locale, '空文件夹', 'Empty folder')}</p>
<p className="text-sm">{pickAppText(locale, '点击上方"上传"或"新建文件夹"按钮开始使用', 'Use "Upload" or "New folder" above to get started')}</p>
</div>
) : (
<ScrollArea className="h-[calc(100vh-15rem)] min-h-[520px]">
<div className="space-y-1 p-2">
{items.map((item) => (
<button
key={item.path}
type="button"
className={`group flex w-full items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors hover:bg-accent/30 ${
selectedFile?.path === item.path ? 'border-primary bg-accent/40' : 'border-border bg-card'
}`}
onClick={() => {
if (item.type === 'directory') {
navigateTo(item.path);
} else {
void openFile(item);
}
}}
>
<div className="flex-shrink-0">
{item.type === 'directory' ? (
<Folder className="w-5 h-5 text-blue-500" />
) : (
<FileIcon name={item.name} contentType={item.content_type} />
)}
</div>
<div className="min-w-0 flex-1">
<div className="truncate text-sm font-medium">{item.name}</div>
<p className="text-xs text-muted-foreground">
{item.type === 'file' && formatSize(item.size)}
{item.modified && (
<>
{item.type === 'file' && ' · '}
{formatDate(item.modified)}
</>
)}
</p>
</div>
<div className="flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100">
{item.type === 'file' && (
<span
role="button"
tabIndex={0}
className="inline-flex h-7 w-7 items-center justify-center rounded-md hover:bg-accent"
onClick={(event) => {
event.stopPropagation();
void handleDownload(item);
}}
onKeyDown={(event) => {
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault();
event.stopPropagation();
void handleDownload(item);
}
}}
title={pickAppText(locale, '下载', 'Download')}
>
<Download className="w-4 h-4" />
</span>
)}
<span
role="button"
tabIndex={0}
className="inline-flex h-7 w-7 items-center justify-center rounded-md text-destructive hover:bg-accent hover:text-destructive"
onClick={(event) => {
event.stopPropagation();
void handleDelete(item);
}}
onKeyDown={(event) => {
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault();
event.stopPropagation();
void handleDelete(item);
}
}}
title={pickAppText(locale, '删除', 'Delete')}
>
<Trash2 className="w-4 h-4" />
</span>
</div>
</button>
))}
</div>
</ScrollArea>
)}
</div>
) : items.length === 0 ? (
<div className="flex flex-col items-center justify-center py-20 text-muted-foreground">
<FolderOpen className="w-12 h-12 mb-4 opacity-50" />
<p className="text-lg font-medium">{pickAppText(locale, '空文件夹', 'Empty folder')}</p>
<p className="text-sm">{pickAppText(locale, '点击上方"上传"或"新建文件夹"按钮开始使用', 'Use "Upload" or "New folder" above to get started')}</p>
<FilePreviewPanel
file={selectedFile}
loading={previewLoading}
error={previewError}
formatSize={formatSize}
formatDate={formatDate}
downloadUrl={selectedFile ? getWorkspaceDownloadUrl(selectedFile.path) : null}
locale={locale}
/>
</div>
</div>
);
}
function FilePreviewPanel({
file,
loading,
error,
formatSize,
formatDate,
downloadUrl,
locale,
}: {
file: WorkspaceFileContent | null;
loading: boolean;
error: string | null;
formatSize: (bytes: number | null) => string;
formatDate: (iso: string) => string;
downloadUrl: string | null;
locale: AppLocale;
}) {
return (
<div className="min-h-[520px] rounded-lg border border-border bg-card p-4">
{loading ? (
<div className="flex h-[420px] items-center justify-center text-muted-foreground">
<Loader2 className="h-6 w-6 animate-spin" />
</div>
) : error ? (
<div className="flex h-[420px] items-center justify-center text-center text-sm text-destructive">{error}</div>
) : !file ? (
<div className="flex h-[420px] flex-col items-center justify-center text-center text-muted-foreground">
<FileText className="mb-3 h-10 w-10 opacity-50" />
<p className="text-sm font-medium">{pickAppText(locale, '点击左侧文件查看内容', 'Click a file to preview its contents')}</p>
</div>
) : (
<ScrollArea className="h-[calc(100vh-14rem)]">
<div className="space-y-1">
{items.map((item) => (
<div
key={item.path}
className="flex items-center gap-3 px-4 py-2.5 rounded-lg border border-border bg-card hover:bg-accent/30 transition-colors group"
>
{/* Icon */}
<div className="flex-shrink-0">
{item.type === 'directory' ? (
<Folder className="w-5 h-5 text-blue-500" />
) : (
<FileIcon name={item.name} contentType={item.content_type} />
)}
</div>
{/* Name - clickable for directories */}
<div className="flex-1 min-w-0">
{item.type === 'directory' ? (
<button
onClick={() => navigateTo(item.path)}
className="text-sm font-medium truncate hover:underline text-left block w-full"
>
{item.name}
</button>
) : (
<p className="text-sm font-medium truncate">{item.name}</p>
)}
<p className="text-xs text-muted-foreground">
{item.type === 'file' && formatSize(item.size)}
{item.modified && (
<>
{item.type === 'file' && ' · '}
{formatDate(item.modified)}
</>
)}
</p>
</div>
{/* Actions */}
<div className="flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity">
{item.type === 'file' && (
<Button
variant="ghost"
size="icon"
className="h-7 w-7"
onClick={() => handleDownload(item)}
title={pickAppText(locale, '下载', 'Download')}
>
<Download className="w-4 h-4" />
</Button>
)}
<Button
variant="ghost"
size="icon"
className="h-7 w-7 text-destructive hover:text-destructive"
onClick={() => handleDelete(item)}
title={pickAppText(locale, '删除', 'Delete')}
>
<Trash2 className="w-4 h-4" />
</Button>
</div>
</div>
))}
<div className="space-y-3">
<div className="flex flex-wrap items-start justify-between gap-3 border-b border-border pb-3">
<div className="min-w-0">
<h2 className="break-all text-base font-semibold">{file.name}</h2>
<p className="mt-1 text-xs text-muted-foreground">
{formatSize(file.size)} · {formatDate(file.modified)} · {file.content_type}
{file.is_truncated ? ` · ${pickAppText(locale, '仅预览前 1MB', 'Showing first 1MB')}` : ''}
</p>
</div>
{downloadUrl && (
<Button variant="outline" size="sm" asChild>
<a href={downloadUrl}>
<Download className="mr-2 h-4 w-4" />
{pickAppText(locale, '下载', 'Download')}
</a>
</Button>
)}
</div>
</ScrollArea>
{isImage(file) && downloadUrl ? (
<div className="flex max-h-[620px] items-start justify-center overflow-auto rounded-md border border-border bg-muted/20 p-3">
{/* eslint-disable-next-line @next/next/no-img-element */}
<img src={downloadUrl} alt={file.name} className="max-h-[580px] max-w-full object-contain" />
</div>
) : file.is_binary ? (
<div className="flex h-[360px] flex-col items-center justify-center text-center text-muted-foreground">
<FileArchive className="mb-3 h-10 w-10 opacity-50" />
<p className="text-sm font-medium">{pickAppText(locale, '该文件不能直接预览', 'This file cannot be previewed')}</p>
</div>
) : isMarkdown(file) ? (
<div className="prose prose-sm max-h-[620px] max-w-none overflow-auto text-black prose-a:text-black prose-code:text-black prose-headings:text-black prose-li:text-black prose-p:text-black prose-pre:bg-muted prose-pre:text-black prose-strong:text-black [&>*:first-child]:mt-0 [&>*:last-child]:mb-0">
<ReactMarkdown remarkPlugins={[remarkGfm]}>{file.content || ''}</ReactMarkdown>
</div>
) : (
<pre className="max-h-[620px] overflow-auto whitespace-pre-wrap rounded-md border border-border bg-background p-4 text-xs leading-5 text-black">
{file.content || ''}
</pre>
)}
</div>
)}
</div>
);
@ -383,3 +515,11 @@ function FileIcon({ name, contentType }: { name: string; contentType?: string })
}
return <FileText className="w-5 h-5 text-muted-foreground" />;
}
function isImage(file: WorkspaceFileContent): boolean {
return file.content_type.startsWith('image/');
}
function isMarkdown(file: WorkspaceFileContent): boolean {
return file.path.toLowerCase().endsWith('.md') || file.content_type.includes('markdown');
}

View File

@ -4,8 +4,10 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { AlertCircle, ArrowLeft, Check, Download, Loader2, Search, Star } from 'lucide-react';
import {
getSkillHubFile,
getSkillHubDetail,
getSkillHubVersion,
getSkillHubVersions,
installSkillHubSkill,
searchSkillHubSkills,
} from '@/lib/api';
@ -13,7 +15,8 @@ import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { Input } from '@/components/ui/input';
import type { SkillHubSearchItem, SkillHubVersionResponse } from '@/types';
import { SkillDetailView } from '@/components/skills/SkillDetailView';
import type { SkillFileContent, SkillHubSearchItem, SkillHubVersionResponse, SkillVersionRef } from '@/types';
import { pickAppText } from '@/lib/i18n/core';
import { useAppI18n } from '@/lib/i18n/provider';
@ -23,6 +26,20 @@ function publishedVersion(skill: SkillHubSearchItem | null): string {
return skill?.publishedVersion?.version || skill?.headlineVersion?.version || '';
}
function readmeFromVersion(version: SkillHubVersionResponse | null): string {
const raw = version?.detail?.parsedMetadataJson;
if (!raw) return '';
try {
const parsed = JSON.parse(raw);
if (parsed && typeof parsed.body === 'string') {
return parsed.body;
}
} catch {
// keep empty fallback
}
return '';
}
export default function MarketplacePage() {
const { locale } = useAppI18n();
const t = useCallback((zh: string, en: string) => pickAppText(locale, zh, en), [locale]);
@ -36,7 +53,13 @@ export default function MarketplacePage() {
const [error, setError] = useState<string | null>(null);
const [selected, setSelected] = useState<SkillHubSearchItem | null>(null);
const [versionDetail, setVersionDetail] = useState<SkillHubVersionResponse | null>(null);
const [versions, setVersions] = useState<SkillVersionRef[]>([]);
const [selectedVersion, setSelectedVersion] = useState('');
const [readmeContent, setReadmeContent] = useState('');
const [selectedFile, setSelectedFile] = useState<SkillFileContent | null>(null);
const [detailLoading, setDetailLoading] = useState(false);
const [versionLoading, setVersionLoading] = useState(false);
const [fileLoading, setFileLoading] = useState(false);
const [installing, setInstalling] = useState(false);
const load = useCallback(async () => {
@ -61,14 +84,25 @@ export default function MarketplacePage() {
const openDetail = async (item: SkillHubSearchItem) => {
setSelected(item);
setVersionDetail(null);
setVersions([]);
setSelectedVersion('');
setReadmeContent('');
setSelectedFile(null);
setDetailLoading(true);
setError(null);
try {
const detail = await getSkillHubDetail(item.namespace, item.slug);
setSelected(detail);
const version = publishedVersion(detail);
const versionList = await getSkillHubVersions(detail.namespace, detail.slug).catch(() => ({
items: version ? [{ version, status: detail.publishedVersion?.status || detail.headlineVersion?.status }] : [],
total: version ? 1 : 0,
page: 0,
size: 1,
}));
setVersions(versionList.items || []);
if (version) {
setVersionDetail(await getSkillHubVersion(detail.namespace, detail.slug, version));
await loadVersion(detail, version);
}
} catch (err: any) {
setError(err.message || t('加载技能详情失败', 'Failed to load skill details'));
@ -77,12 +111,51 @@ export default function MarketplacePage() {
}
};
const loadVersion = async (skill: SkillHubSearchItem, version: string) => {
setVersionLoading(true);
setSelectedVersion(version);
setSelectedFile(null);
try {
const nextVersion = await getSkillHubVersion(skill.namespace, skill.slug, version);
setVersionDetail(nextVersion);
const readme = await getSkillHubFile(skill.namespace, skill.slug, version, 'SKILL.md')
.then((file) => file.content || '')
.catch(() => readmeFromVersion(nextVersion));
setReadmeContent(readme);
} finally {
setVersionLoading(false);
}
};
const openVersion = async (version: string) => {
if (!selected || selectedVersion === version) return;
setError(null);
try {
await loadVersion(selected, version);
} catch (err: any) {
setError(err.message || t('加载技能版本失败', 'Failed to load skill version'));
}
};
const openFile = async (filePath: string) => {
if (!selected || !selectedVersion) return;
setFileLoading(true);
setError(null);
try {
setSelectedFile(await getSkillHubFile(selected.namespace, selected.slug, selectedVersion, filePath));
} catch (err: any) {
setError(err.message || t('加载文件失败', 'Failed to load file'));
} finally {
setFileLoading(false);
}
};
const installSelected = async () => {
if (!selected) return;
setInstalling(true);
setError(null);
try {
const result = await installSkillHubSkill(selected.namespace, selected.slug, publishedVersion(selected));
const result = await installSkillHubSkill(selected.namespace, selected.slug, selectedVersion || publishedVersion(selected));
setSelected({ ...selected, installed: true, installed_version: result.version });
await load();
} catch (err: any) {
@ -131,67 +204,71 @@ export default function MarketplacePage() {
{selected ? (
<div className="space-y-5">
<Button variant="ghost" onClick={() => setSelected(null)}>
<Button
variant="ghost"
onClick={() => {
setSelected(null);
setVersionDetail(null);
setVersions([]);
setSelectedVersion('');
setReadmeContent('');
setSelectedFile(null);
}}
>
<ArrowLeft className="mr-2 h-4 w-4" />
{t('返回搜索', 'Back to search')}
</Button>
<Card>
<CardHeader>
<div className="flex flex-wrap items-start justify-between gap-4">
<div>
<div className="mb-2 flex items-center gap-2">
<Badge variant="outline">@{selected.namespace}</Badge>
{selected.installed && (
<Badge variant="secondary" className="gap-1">
<Check className="h-3 w-3" />
{t('已安装', 'Installed')}
</Badge>
)}
</div>
<CardTitle className="text-2xl">{selected.displayName || selected.slug}</CardTitle>
<p className="mt-3 max-w-3xl text-sm leading-6 text-muted-foreground">{selected.summary}</p>
</div>
<Button onClick={installSelected} disabled={installing || detailLoading}>
{detailLoading ? (
<Card>
<CardContent className="flex justify-center py-16">
<Loader2 className="h-5 w-5 animate-spin text-muted-foreground" />
</CardContent>
</Card>
) : (
<SkillDetailView
title={selected.displayName || selected.slug}
summary={selected.summary}
currentVersion={selectedVersion || publishedVersion(selected)}
versions={versions.length > 0 ? versions : [{ version: selectedVersion || publishedVersion(selected) }]}
files={versionDetail?.files || []}
content={readmeContent || readmeFromVersion(versionDetail)}
selectedFile={selectedFile}
loadingFile={fileLoading}
loadingVersion={versionLoading}
onSelectVersion={(version) => void openVersion(version)}
onOpenFile={(filePath) => void openFile(filePath)}
badges={
<>
<Badge variant="outline">@{selected.namespace}</Badge>
<Badge variant="outline">{t('下载', 'Downloads')}: {selected.downloadCount || 0}</Badge>
<Badge variant="outline">{t('收藏', 'Stars')}: {selected.starCount || 0}</Badge>
{selected.installed && (
<Badge variant="secondary" className="gap-1">
<Check className="h-3 w-3" />
{t('已安装', 'Installed')}
</Badge>
)}
</>
}
actions={
<Button onClick={installSelected} disabled={installing || detailLoading || versionLoading}>
{installing ? <Loader2 className="mr-2 h-4 w-4 animate-spin" /> : <Download className="mr-2 h-4 w-4" />}
{selected.installed ? t('重新安装/更新', 'Reinstall/update') : t('安装', 'Install')}
</Button>
</div>
</CardHeader>
<CardContent className="space-y-4">
{detailLoading ? (
<div className="flex justify-center py-10">
<Loader2 className="h-5 w-5 animate-spin text-muted-foreground" />
</div>
) : (
<>
<div className="flex flex-wrap gap-2 text-sm text-muted-foreground">
<Badge variant="outline">v{publishedVersion(selected) || '-'}</Badge>
<span>{t('下载', 'Downloads')}: {selected.downloadCount || 0}</span>
<span>{t('收藏', 'Stars')}: {selected.starCount || 0}</span>
</div>
<div className="grid gap-4 lg:grid-cols-[minmax(0,1.2fr)_minmax(320px,0.8fr)]">
<div className="rounded-lg border border-border bg-muted/20 p-4">
<div className="mb-2 text-sm font-medium">SKILL.md</div>
<pre className="max-h-[520px] overflow-auto whitespace-pre-wrap text-xs">
{versionDetail?.detail?.parsedMetadataJson || t('暂无预览', 'No preview available')}
</pre>
</div>
<div className="rounded-lg border border-border bg-muted/20 p-4">
<div className="mb-3 text-sm font-medium">{t('版本文件', 'Version files')}</div>
<div className="space-y-2">
{(versionDetail?.files || []).map((file) => (
<div key={file.filePath} className="flex items-center justify-between gap-3 rounded-md bg-background px-3 py-2 text-xs">
<span className="break-all font-mono">{file.filePath}</span>
<span className="shrink-0 text-muted-foreground">{file.fileSize} B</span>
</div>
))}
</div>
</div>
</div>
</>
)}
</CardContent>
</Card>
}
labels={{
overview: t('说明', 'Overview'),
files: t('文件', 'Files'),
versions: t('版本', 'Versions'),
noReadme: t('暂无说明', 'No overview available'),
noFiles: t('暂无文件', 'No files'),
selectFile: t('选择一个文件查看详情', 'Select a file to view details'),
binaryFile: t('二进制文件暂不预览', 'Binary file preview is not available'),
current: t('当前', 'Current'),
size: t('大小', 'Size'),
}}
/>
)}
</div>
) : (
<div className="space-y-6">

File diff suppressed because it is too large Load Diff

View File

@ -191,15 +191,6 @@ export default function StatusPage() {
if (!status) return null;
const settingsLinks = [
{
href: '/logs',
icon: ScrollText,
title: pickAppText(locale, '运行日志', 'Runtime Logs'),
description: pickAppText(locale, '查看每次对话和后台任务的运行日志。', 'Inspect chat and background runtime logs.'),
},
];
return (
<div className="mx-auto max-w-6xl p-6 space-y-6">
<div className="flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between">
@ -219,27 +210,6 @@ export default function StatusPage() {
</Button>
</div>
<div className="grid gap-3 md:grid-cols-2 xl:grid-cols-3">
{settingsLinks.map((item) => {
const Icon = item.icon;
return (
<Link
key={item.href}
href={item.href}
className="group flex min-h-[116px] items-start gap-4 rounded-lg border border-border bg-background p-4 transition-colors hover:border-primary/50 hover:bg-muted/40"
>
<span className="mt-0.5 rounded-md border border-border bg-muted p-2 text-muted-foreground group-hover:text-primary">
<Icon className="h-4 w-4" />
</span>
<span className="min-w-0 space-y-1">
<span className="block text-sm font-semibold text-foreground">{item.title}</span>
<span className="block text-sm leading-6 text-muted-foreground">{item.description}</span>
</span>
</Link>
);
})}
</div>
{/* System Info */}
<Card>
<CardHeader>

View File

@ -3,7 +3,7 @@
import React from 'react';
import Link from 'next/link';
import { usePathname, useRouter } from 'next/navigation';
import { Bell, Bot, ChevronDown, ListTodo, LogOut, Mail, MessageSquare, PackageOpen, Puzzle, Settings, Store, Wrench } from 'lucide-react';
import { Bell, Bot, ChevronDown, FolderOpen, ListTodo, LogOut, Mail, MessageSquare, PackageOpen, Puzzle, Settings, Store, Wrench } from 'lucide-react';
import { logout } from '@/lib/api';
import { LanguageSwitcher } from '@/components/LanguageSwitcher';
import { Avatar, AvatarFallback } from '@/components/ui/avatar';
@ -15,7 +15,7 @@ import { useAppI18n } from '@/lib/i18n/provider';
import { useChatStore } from '@/lib/store';
type NavItem = {
key: 'chat' | 'tasks' | 'notifications' | 'skills' | 'tools' | 'agents' | 'outlook' | 'marketplace' | 'plugins' | 'settings';
key: 'chat' | 'tasks' | 'notifications' | 'skills' | 'files' | 'tools' | 'agents' | 'outlook' | 'marketplace' | 'plugins' | 'settings';
href: string;
icon: React.ComponentType<{ className?: string }>;
matchPrefixes?: string[];
@ -26,6 +26,7 @@ const NAV_ITEMS: NavItem[] = [
{ key: 'tasks', href: '/tasks', icon: ListTodo, matchPrefixes: ['/tasks', '/office', '/cron'] },
{ key: 'notifications', href: '/notifications', icon: Bell, matchPrefixes: ['/notifications'] },
{ key: 'skills', href: '/skills', icon: Puzzle },
{ key: 'files', href: '/files', icon: FolderOpen, matchPrefixes: ['/files'] },
{ key: 'tools', href: '/mcp', icon: Wrench, matchPrefixes: ['/mcp'] },
{ key: 'agents', href: '/agents', icon: Bot, matchPrefixes: ['/agents'] },
{ key: 'outlook', href: '/outlook', icon: Mail, matchPrefixes: ['/outlook'] },
@ -78,6 +79,7 @@ const Header = () => {
if (key === 'tasks') return 'Task';
if (key === 'notifications') return pickAppText(locale, '通知', 'Notifications');
if (key === 'skills') return pickAppText(locale, '技能', 'Skills');
if (key === 'files') return pickAppText(locale, '文件', 'Files');
if (key === 'tools') return pickAppText(locale, '工具', 'Tools');
if (key === 'agents') return pickAppText(locale, '智能体', 'Agents');
if (key === 'outlook') return 'Outlook';

View File

@ -0,0 +1,222 @@
'use client';
import React from 'react';
import { FileText, GitBranch, Loader2 } from 'lucide-react';
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm';
import { Badge } from '@/components/ui/badge';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
import type { SkillFileContent, SkillFileInfo, SkillVersionRef } from '@/types';
type SkillDetailViewProps = {
title: string;
summary?: string | null;
badges?: React.ReactNode;
actions?: React.ReactNode;
currentVersion: string;
versions: SkillVersionRef[];
files: SkillFileInfo[];
content: string;
selectedFile?: SkillFileContent | null;
loadingFile?: boolean;
loadingVersion?: boolean;
onSelectVersion: (version: string) => void;
onOpenFile: (filePath: string) => void;
labels: {
overview: string;
files: string;
versions: string;
noReadme: string;
noFiles: string;
selectFile: string;
binaryFile: string;
current: string;
size: string;
};
};
export function SkillDetailView({
title,
summary,
badges,
actions,
currentVersion,
versions,
files,
content,
selectedFile,
loadingFile,
loadingVersion,
onSelectVersion,
onOpenFile,
labels,
}: SkillDetailViewProps) {
const readme = stripFrontmatter(content || '');
return (
<div className="rounded-lg border border-border bg-white text-black [--background:0_0%_100%] [--card:0_0%_100%] [--card-foreground:0_0%_0%] [--foreground:0_0%_0%] [--muted-foreground:0_0%_0%] [--popover:0_0%_100%] [--popover-foreground:0_0%_0%] [--secondary-foreground:0_0%_0%]">
<div className="border-b border-border p-5">
<div className="flex flex-wrap items-start justify-between gap-4">
<div className="min-w-0">
<div className="mb-2 flex flex-wrap items-center gap-2">
{badges}
<Badge variant="outline">v{currentVersion || '-'}</Badge>
{loadingVersion && <Loader2 className="h-4 w-4 animate-spin text-muted-foreground" />}
</div>
<h2 className="break-words text-2xl font-semibold tracking-normal">{title}</h2>
{summary && <p className="mt-2 max-w-4xl text-sm leading-6 text-muted-foreground">{summary}</p>}
</div>
{actions}
</div>
</div>
<Tabs defaultValue="overview" className="p-5">
<TabsList>
<TabsTrigger value="overview">{labels.overview}</TabsTrigger>
<TabsTrigger value="files">{labels.files}</TabsTrigger>
<TabsTrigger value="versions">{labels.versions}</TabsTrigger>
</TabsList>
<TabsContent value="overview" className="mt-5">
{readme.trim() ? (
<MarkdownPreview content={readme} />
) : (
<EmptyPanel icon={<FileText className="h-7 w-7" />} text={labels.noReadme} />
)}
</TabsContent>
<TabsContent value="files" className="mt-5">
<div className="grid gap-4 lg:grid-cols-[320px_minmax(0,1fr)]">
<div className="min-h-[420px] rounded-lg border border-border">
{files.length === 0 ? (
<EmptyPanel icon={<FileText className="h-7 w-7" />} text={labels.noFiles} />
) : (
<div className="max-h-[620px] overflow-auto p-2">
{files.map((file) => (
<button
key={file.filePath}
type="button"
className={`flex w-full items-center justify-between gap-3 rounded-md px-3 py-2 text-left text-sm transition hover:bg-muted ${
selectedFile?.filePath === file.filePath ? 'bg-muted' : ''
}`}
onClick={() => onOpenFile(file.filePath)}
>
<span className="min-w-0 break-all font-mono text-xs">{file.filePath}</span>
<span className="shrink-0 text-xs text-muted-foreground">{formatBytes(file.fileSize)}</span>
</button>
))}
</div>
)}
</div>
<div className="min-h-[420px] rounded-lg border border-border bg-muted/20 p-4">
{loadingFile ? (
<div className="flex h-[360px] items-center justify-center">
<Loader2 className="h-5 w-5 animate-spin text-muted-foreground" />
</div>
) : selectedFile ? (
<FilePreview file={selectedFile} labels={labels} />
) : (
<EmptyPanel icon={<FileText className="h-7 w-7" />} text={labels.selectFile} />
)}
</div>
</div>
</TabsContent>
<TabsContent value="versions" className="mt-5">
<div className="space-y-2">
{versions.map((version) => (
<button
key={version.version}
type="button"
className={`flex w-full items-center justify-between gap-4 rounded-lg border px-4 py-3 text-left transition hover:bg-muted ${
version.version === currentVersion ? 'border-primary bg-muted' : 'border-border'
}`}
onClick={() => onSelectVersion(version.version)}
>
<div className="min-w-0">
<div className="flex flex-wrap items-center gap-2">
<GitBranch className="h-4 w-4 text-muted-foreground" />
<span className="font-mono text-sm">{version.version}</span>
{version.version === currentVersion && <Badge variant="secondary">{labels.current}</Badge>}
{version.status && <Badge variant="outline">{version.status}</Badge>}
</div>
{version.changeReason && (
<p className="mt-1 truncate text-xs text-muted-foreground">{version.changeReason}</p>
)}
</div>
<div className="shrink-0 text-right text-xs text-muted-foreground">
{version.publishedAt || version.createdAt || ''}
{typeof version.totalSize === 'number' && (
<div>
{labels.size}: {formatBytes(version.totalSize)}
</div>
)}
</div>
</button>
))}
</div>
</TabsContent>
</Tabs>
</div>
);
}
function FilePreview({ file, labels }: { file: SkillFileContent; labels: SkillDetailViewProps['labels'] }) {
const content = file.content || '';
return (
<div className="space-y-3">
<div className="flex flex-wrap items-center justify-between gap-2">
<div className="break-all font-mono text-sm font-medium">{file.filePath}</div>
<Badge variant="outline">
{labels.size}: {formatBytes(file.fileSize)}
</Badge>
</div>
{file.isBinary ? (
<EmptyPanel icon={<FileText className="h-7 w-7" />} text={labels.binaryFile} />
) : isMarkdown(file.filePath, file.contentType) ? (
<MarkdownPreview content={stripFrontmatter(content)} />
) : (
<pre className="max-h-[560px] overflow-auto rounded-md border border-border bg-background p-4 text-xs leading-5">
{content}
</pre>
)}
</div>
);
}
function MarkdownPreview({ content }: { content: string }) {
return (
<div className="prose prose-sm max-w-none text-black prose-a:text-black prose-blockquote:text-black prose-code:rounded prose-code:bg-muted prose-code:px-1 prose-code:py-0.5 prose-code:text-black prose-headings:text-black prose-headings:tracking-normal prose-li:text-black prose-p:text-black prose-pre:border prose-pre:border-border prose-pre:bg-muted prose-pre:text-black prose-strong:text-black prose-table:text-black prose-td:text-black prose-th:text-black [&>*:first-child]:mt-0 [&>*:last-child]:mb-0">
<ReactMarkdown remarkPlugins={[remarkGfm]}>{content}</ReactMarkdown>
</div>
);
}
function EmptyPanel({ icon, text }: { icon: React.ReactNode; text: string }) {
return (
<div className="flex min-h-[220px] flex-col items-center justify-center text-center text-muted-foreground">
<div className="mb-3 opacity-40">{icon}</div>
<p className="text-sm font-medium">{text}</p>
</div>
);
}
function stripFrontmatter(value: string): string {
if (!value.startsWith('---')) return value;
const marker = value.indexOf('\n---', 3);
if (marker < 0) return value;
const after = value.indexOf('\n', marker + 4);
return after >= 0 ? value.slice(after + 1) : '';
}
function isMarkdown(filePath: string, contentType?: string | null): boolean {
return filePath.toLowerCase().endsWith('.md') || (contentType || '').includes('markdown');
}
function formatBytes(value: number | undefined): string {
const size = Number(value || 0);
if (size < 1024) return `${size} B`;
if (size < 1024 * 1024) return `${(size / 1024).toFixed(1)} KB`;
return `${(size / 1024 / 1024).toFixed(1)} MB`;
}

View File

@ -21,13 +21,16 @@ import type {
Session,
SessionDetail,
Skill,
SkillDetailResponse,
SkillDraft,
SkillDraftEvalReport,
SkillDraftSafetyReport,
SkillFileContent,
SkillHubInstallResponse,
SkillHubSearchItem,
SkillHubSearchResponse,
SkillHubVersionResponse,
SkillHubVersionsResponse,
SkillLearningCandidate,
SkillReviewRecord,
SlashCommand,
@ -56,6 +59,7 @@ const ACCESS_TOKEN_KEY = 'nanobot_access_token';
const REFRESH_TOKEN_KEY = 'nanobot_refresh_token';
const REQUEST_TIMEOUT_MS = 8000;
const OUTLOOK_REQUEST_TIMEOUT_MS = 45000;
const SKILL_LEARNING_REQUEST_TIMEOUT_MS = 120000;
function isBrowser(): boolean {
return typeof window !== 'undefined';
@ -728,6 +732,21 @@ export async function listSkills(): Promise<Skill[]> {
return fetchJSON('/api/skills');
}
export async function getSkillDetail(skillName: string): Promise<SkillDetailResponse> {
return fetchJSON(`/api/skills/${encodeURIComponent(skillName)}/detail`);
}
export async function getSkillVersion(skillName: string, version: string): Promise<SkillDetailResponse> {
return fetchJSON(`/api/skills/${encodeURIComponent(skillName)}/versions/${encodeURIComponent(version)}`);
}
export async function getSkillFile(skillName: string, version: string, filePath: string): Promise<SkillFileContent> {
const search = new URLSearchParams({ path: filePath });
return fetchJSON(
`/api/skills/${encodeURIComponent(skillName)}/versions/${encodeURIComponent(version)}/file?${search.toString()}`
);
}
export async function listSkillCandidates(status?: string): Promise<SkillLearningCandidate[]> {
const query = status ? `?status=${encodeURIComponent(status)}` : '';
return fetchJSON(`/api/skills/candidates${query}`);
@ -737,6 +756,7 @@ export async function synthesizeSkillDraft(candidateId: string): Promise<SkillDr
return fetchJSON(`/api/skills/candidates/${encodeURIComponent(candidateId)}/draft`, {
method: 'POST',
body: JSON.stringify({}),
timeoutMs: SKILL_LEARNING_REQUEST_TIMEOUT_MS,
});
}
@ -744,6 +764,7 @@ export async function regenerateSkillDraft(candidateId: string): Promise<SkillDr
return fetchJSON(`/api/skills/candidates/${encodeURIComponent(candidateId)}/regenerate`, {
method: 'POST',
body: JSON.stringify({}),
timeoutMs: SKILL_LEARNING_REQUEST_TIMEOUT_MS,
});
}
@ -757,6 +778,7 @@ export async function runSkillLearningOnce(): Promise<{
return fetchJSON('/api/skills/learning/run-once', {
method: 'POST',
body: JSON.stringify({}),
timeoutMs: SKILL_LEARNING_REQUEST_TIMEOUT_MS,
});
}
@ -1301,6 +1323,24 @@ export async function getSkillHubVersion(
);
}
export async function getSkillHubVersions(namespace: string, slug: string): Promise<SkillHubVersionsResponse> {
return fetchJSON(
`/api/marketplaces/skills/${encodeURIComponent(namespace.replace(/^@/, ''))}/${encodeURIComponent(slug)}/versions`
);
}
export async function getSkillHubFile(
namespace: string,
slug: string,
version: string,
filePath: string
): Promise<SkillFileContent> {
const search = new URLSearchParams({ path: filePath });
return fetchJSON(
`/api/marketplaces/skills/${encodeURIComponent(namespace.replace(/^@/, ''))}/${encodeURIComponent(slug)}/versions/${encodeURIComponent(version)}/file?${search.toString()}`
);
}
export async function installSkillHubSkill(
namespace: string,
slug: string,
@ -1441,11 +1481,26 @@ export interface BrowseResult {
items: WorkspaceItem[];
}
export interface WorkspaceFileContent {
name: string;
path: string;
size: number;
content_type: string;
modified: string;
is_binary: boolean;
is_truncated: boolean;
content: string | null;
}
export async function browseWorkspace(path: string = ''): Promise<BrowseResult> {
const params = path ? `?path=${encodeURIComponent(path)}` : '';
return fetchJSON(`/api/workspace/browse${params}`);
}
export async function getWorkspaceFile(path: string): Promise<WorkspaceFileContent> {
return fetchJSON(`/api/workspace/file?path=${encodeURIComponent(path)}`);
}
export function getWorkspaceDownloadUrl(path: string): string {
return buildApiUrl(`/api/workspace/download?path=${encodeURIComponent(path)}`);
}

View File

@ -178,9 +178,50 @@ export interface Skill {
source: 'builtin' | 'workspace';
available: boolean;
path: string;
version?: string;
status?: string;
source_kind?: string;
tool_hints?: string[];
provenance?: Record<string, unknown>;
agent_cards?: Record<string, unknown>[];
}
export interface SkillVersionRef {
version: string;
status?: string | null;
createdAt?: string | null;
publishedAt?: string | null;
changeReason?: string | null;
parentVersion?: string | null;
contentHash?: string | null;
fileCount?: number;
totalSize?: number;
}
export interface SkillFileInfo {
id?: number;
filePath: string;
fileSize: number;
contentType?: string | null;
sha256?: string | null;
}
export interface SkillFileContent extends SkillFileInfo {
content?: string | null;
isBinary?: boolean;
}
export interface SkillDetailResponse {
skill: Skill;
spec?: Record<string, unknown> | null;
currentVersion: string;
versions: SkillVersionRef[];
versionDetail?: Record<string, unknown> | null;
files: SkillFileInfo[];
content: string;
frontmatter?: Record<string, unknown>;
}
export interface SlashCommand {
name: string;
description: string;
@ -385,6 +426,13 @@ export interface SkillHubSearchResponse {
size: number;
}
export interface SkillHubVersionsResponse {
items: SkillVersionRef[];
total: number;
page: number;
size: number;
}
export interface SkillHubFileInfo {
id?: number;
filePath: string;