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

@ -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">