feat(delegation): 添加直连模式下的委托公告回调机制
- 引入 DirectAnnouncementCallback 类型用于处理直连模式下的公告 - 在 DelegationManager 中添加 _direct_announcement_callback 属性和设置方法 - 实现 _notify_direct_announcement 方法用于在非总线模式下将公告回写到本地会话 - 在委托取消、完成和分组完成时添加对直连公告的通知逻辑 feat(web): 增加 WebSocket 广播器支持实时会话更新通知 - 创建 WebSocketBroadcaster 类用于跟踪认证的 WebSocket 连接并广播 JSON 事件 - 在应用启动时初始化 websocket_broadcaster 实例 - 实现连接注册、注销和消息广播功能 - 添加过期连接清理机制 feat(agent): 新增系统公告处理方法支持本地处理 - 在 AgentLoop 中添加 process_system_announcement 方法用于在无常驻 run() 场景下处理系统公告 - 创建 InboundMessage 并通过 _process_message 进行处理 feat(cron): 改进定时任务的会话路由解析和实时更新 - 添加 _resolve_cron_session_key 和 _infer_cron_route_from_session_key 辅助函数 - 在 cron 任务执行完成后通过 WebSocket 广播会话更新事件 - 在添加定时任务时自动推断目标会话的渠道和聊天 ID refactor: 项目名称从 Boardware Genius 统一改为 Boardware Agent Sandbox - 更新前端页面标题和描述文本中的产品名称 - 添加新的品牌 Logo 图片资源 - 在前端布局中使用新的 Logo 显示 - 更新授权门户中的品牌信息和 Logo 显示 feat(frontend): 添加会话更新事件监听实现消息自动刷新 - 定义 SessionUpdatedEvent 类型接口 - 在 ChatPage 中添加会话更新事件的处理逻辑 - 当收到会话更新事件时自动重新加载会话列表和当前会话消息 feat(api): 扩展定时任务 API 支持会话键参数 - 在 addCronJob API 参数中添加 session_key 字段 - 更新前端 Cron 页面的表单处理以传递当前会话键
This commit is contained in:
@ -39,13 +39,16 @@ import {
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/components/ui/select';
|
||||
import { useChatStore } from '@/lib/store';
|
||||
import type { CronJob } from '@/types';
|
||||
|
||||
export default function CronPage() {
|
||||
const sessionId = useChatStore((s) => s.sessionId);
|
||||
const [jobs, setJobs] = useState<CronJob[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [showAdd, setShowAdd] = useState(false);
|
||||
const targetSessionKey = sessionId.startsWith('web:') ? sessionId : 'web:default';
|
||||
|
||||
const loadJobs = async () => {
|
||||
setLoading(true);
|
||||
@ -98,7 +101,10 @@ export default function CronPage() {
|
||||
cron_expr?: string;
|
||||
}) => {
|
||||
try {
|
||||
await addCronJob(params);
|
||||
await addCronJob({
|
||||
...params,
|
||||
session_key: targetSessionKey,
|
||||
});
|
||||
setShowAdd(false);
|
||||
loadJobs();
|
||||
} catch (err: any) {
|
||||
@ -157,6 +163,7 @@ export default function CronPage() {
|
||||
{/* Add Job Form */}
|
||||
{showAdd && (
|
||||
<AddJobForm
|
||||
targetSessionKey={targetSessionKey}
|
||||
onAdd={handleAdd}
|
||||
onCancel={() => setShowAdd(false)}
|
||||
/>
|
||||
@ -271,9 +278,11 @@ export default function CronPage() {
|
||||
}
|
||||
|
||||
function AddJobForm({
|
||||
targetSessionKey,
|
||||
onAdd,
|
||||
onCancel,
|
||||
}: {
|
||||
targetSessionKey: string;
|
||||
onAdd: (params: {
|
||||
name: string;
|
||||
message: string;
|
||||
@ -382,6 +391,9 @@ function AddJobForm({
|
||||
onChange={(e) => setMessage(e.target.value)}
|
||||
placeholder="例如:检查我的邮件并生成摘要"
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
任务结果会自动回写到当前 Web 会话:<code className="bg-muted px-1 py-0.5 rounded">{targetSessionKey}</code>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-end gap-2">
|
||||
|
||||
@ -61,7 +61,7 @@ export default function HelpPage() {
|
||||
<div className="max-w-2xl mx-auto px-4 py-8 space-y-4">
|
||||
<div className="mb-6">
|
||||
<h1 className="text-2xl font-bold mb-1">使用帮助</h1>
|
||||
<p className="text-muted-foreground text-sm">了解如何使用 Boardware Genius 的各项功能</p>
|
||||
<p className="text-muted-foreground text-sm">了解如何使用 Boardware Agent Sandbox 的各项功能</p>
|
||||
</div>
|
||||
|
||||
<Section icon={<MessageSquare className="w-5 h-5" />} title="如何开始对话" defaultOpen>
|
||||
@ -69,7 +69,7 @@ export default function HelpPage() {
|
||||
<ol className="list-decimal list-inside space-y-1.5 ml-1">
|
||||
<li>在底部输入框中输入你的问题或指令</li>
|
||||
<li>按 <Tag>Enter</Tag> 发送,按 <Tag>Shift + Enter</Tag> 换行</li>
|
||||
<li>等待 Boardware Genius 回复(右上角会显示"思考中...")</li>
|
||||
<li>等待 Boardware Agent Sandbox 回复(右上角会显示"思考中...")</li>
|
||||
</ol>
|
||||
<p className="mt-1">
|
||||
点击左上角的 <Tag>新对话</Tag> 按钮可以开启一个全新的对话,历史对话会保存在左侧列表中。
|
||||
@ -111,7 +111,7 @@ export default function HelpPage() {
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="w-2 h-2 rounded-full bg-green-500 flex-shrink-0" />
|
||||
<Tag color="green">已连接</Tag>
|
||||
<span>— Boardware Genius 服务正常运行,可以正常对话</span>
|
||||
<span>— Boardware Agent Sandbox 服务正常运行,可以正常对话</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="w-2 h-2 rounded-full bg-yellow-500 flex-shrink-0" />
|
||||
@ -121,7 +121,7 @@ export default function HelpPage() {
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="w-2 h-2 rounded-full bg-red-500 flex-shrink-0" />
|
||||
<Tag color="red">服务离线</Tag>
|
||||
<span>— 已连到后端接口,但 Boardware Genius 服务当前不可用</span>
|
||||
<span>— 已连到后端接口,但 Boardware Agent Sandbox 服务当前不可用</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="w-2 h-2 rounded-full bg-red-500 flex-shrink-0" />
|
||||
@ -150,7 +150,7 @@ export default function HelpPage() {
|
||||
<p>请检查右上角连接状态是否为"已连接"。若显示"服务离线"或"未连接",说明后端服务未运行,消息无法被处理。</p>
|
||||
</div>
|
||||
<div>
|
||||
<p className="font-medium text-foreground mb-1">Q:如何查看 Boardware Genius 的运行状态?</p>
|
||||
<p className="font-medium text-foreground mb-1">Q:如何查看 Boardware Agent Sandbox 的运行状态?</p>
|
||||
<p>点击顶部导航栏的<strong className="text-foreground">状态</strong>页面,可以查看服务配置、AI 模型、各通道和定时任务的运行状况。</p>
|
||||
</div>
|
||||
<div>
|
||||
@ -159,7 +159,7 @@ export default function HelpPage() {
|
||||
</div>
|
||||
<div>
|
||||
<p className="font-medium text-foreground mb-1">Q:什么是技能和插件?</p>
|
||||
<p><strong className="text-foreground">技能</strong>是可上传的自定义提示词包,扩展 Boardware Genius 的能力范围。<strong className="text-foreground">插件</strong>是更完整的功能扩展,可以提供新的斜杠命令、专用 Agent 等。</p>
|
||||
<p><strong className="text-foreground">技能</strong>是可上传的自定义提示词包,扩展 Boardware Agent Sandbox 的能力范围。<strong className="text-foreground">插件</strong>是更完整的功能扩展,可以提供新的斜杠命令、专用 Agent 等。</p>
|
||||
</div>
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
@ -20,7 +20,7 @@ import {
|
||||
wsManager,
|
||||
} from '@/lib/api';
|
||||
import { useChatStore } from '@/lib/store';
|
||||
import type { ChatMessage, FileAttachment, ProcessWsEvent, SlashCommand, WsEvent } from '@/types';
|
||||
import type { ChatMessage, FileAttachment, ProcessWsEvent, SessionUpdatedEvent, SlashCommand, WsEvent } from '@/types';
|
||||
|
||||
function scheduleWhenIdle(task: () => void, timeout = 1200): () => void {
|
||||
if (typeof window === 'undefined') {
|
||||
@ -78,6 +78,10 @@ function isProcessEvent(data: WsEvent | Record<string, unknown>): data is Proces
|
||||
return type.startsWith('process_') || type === 'process_cancel_ack';
|
||||
}
|
||||
|
||||
function isSessionUpdatedEvent(data: WsEvent | Record<string, unknown>): data is SessionUpdatedEvent {
|
||||
return data.type === 'session_updated' && typeof data.session_id === 'string';
|
||||
}
|
||||
|
||||
export default function ChatPage() {
|
||||
const {
|
||||
sessionId,
|
||||
@ -235,6 +239,14 @@ export default function ChatPage() {
|
||||
});
|
||||
|
||||
const unsubMessage = wsManager.onMessage((data) => {
|
||||
if (isSessionUpdatedEvent(data)) {
|
||||
void loadSessions();
|
||||
if (data.session_id === useChatStore.getState().sessionId) {
|
||||
void loadSessionMessages(data.session_id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (isProcessEvent(data)) {
|
||||
ingestProcessEvent(data);
|
||||
return;
|
||||
|
||||
@ -92,7 +92,7 @@ export default function PluginsPage() {
|
||||
<p className="font-medium">还没有安装任何插件</p>
|
||||
<p className="text-sm mt-2 max-w-sm mx-auto">
|
||||
把插件目录放到 <code className="text-xs bg-muted px-1 py-0.5 rounded">~/.nanobot/plugins/</code>,
|
||||
然后重启 Boardware Genius。
|
||||
然后重启 Boardware Agent Sandbox。
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
@ -57,7 +57,7 @@ export default function StatusPage() {
|
||||
<div className="flex items-center gap-3 text-destructive">
|
||||
<AlertCircle className="w-5 h-5" />
|
||||
<div>
|
||||
<p className="font-medium">无法连接到 Boardware Genius 后端</p>
|
||||
<p className="font-medium">无法连接到 Boardware Agent Sandbox 后端</p>
|
||||
<p className="text-sm text-muted-foreground mt-1">{error}</p>
|
||||
<p className="text-sm text-muted-foreground mt-1">
|
||||
请确认后端已启动:<code className="bg-muted px-1 rounded">nanobot web</code>
|
||||
|
||||
@ -2,8 +2,11 @@ import './globals.css';
|
||||
import type { Metadata } from 'next';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Boardware Genius',
|
||||
title: 'Boardware Agent Sandbox',
|
||||
description: '个人 AI 助手',
|
||||
icons: {
|
||||
icon: '/boardware-logo.svg',
|
||||
},
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
import React from 'react';
|
||||
import Link from 'next/link';
|
||||
import Image from 'next/image';
|
||||
import { usePathname, useRouter } from 'next/navigation';
|
||||
import { MessageSquare, Activity, Clock, Puzzle, Blocks, HelpCircle, FolderOpen, Store, LogIn, UserPlus, Bot, ServerCog, Mail, LogOut, UserCircle2 } from 'lucide-react';
|
||||
import { logout } from '@/lib/api';
|
||||
@ -75,46 +76,57 @@ const Header = () => {
|
||||
|
||||
return (
|
||||
<header className="fixed top-0 left-0 right-0 bg-background border-b border-border z-50">
|
||||
<div className="max-w-[1560px] mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div className="flex justify-between items-center h-16 gap-4">
|
||||
<Link href="/" className="flex items-center space-x-2">
|
||||
<span className="text-xl">🐈</span>
|
||||
<span className="text-base font-bold sm:text-lg">Boardware Genius</span>
|
||||
<div className="max-w-[1720px] mx-auto px-5 sm:px-6 lg:px-8 xl:px-10">
|
||||
<div className="flex items-center h-16 gap-6">
|
||||
<Link href="/" className="flex shrink-0 items-center gap-3 pr-2">
|
||||
<Image
|
||||
src="/boardware-logo.svg"
|
||||
alt="Boardware logo"
|
||||
width={40}
|
||||
height={32}
|
||||
className="h-8 w-10 shrink-0 rounded-sm bg-white object-contain p-0.5"
|
||||
/>
|
||||
<span className="whitespace-nowrap text-[1.05rem] font-semibold leading-none tracking-tight sm:text-[1.15rem]">
|
||||
Boardware Agent Sandbox
|
||||
</span>
|
||||
</Link>
|
||||
|
||||
<nav className="flex items-center gap-1.5 whitespace-nowrap">
|
||||
{NAV_ITEMS.map((item) => {
|
||||
const isActive =
|
||||
item.href === '/'
|
||||
? pathname === '/'
|
||||
: pathname.startsWith(item.href);
|
||||
const Icon = item.icon;
|
||||
return (
|
||||
<Link
|
||||
key={item.href}
|
||||
href={item.href}
|
||||
className={`flex items-center gap-1.5 px-3.5 py-2 rounded-md text-sm font-medium transition-colors ${
|
||||
isActive
|
||||
? 'bg-primary text-primary-foreground'
|
||||
: 'text-muted-foreground hover:bg-accent hover:text-accent-foreground'
|
||||
}`}
|
||||
>
|
||||
<Icon className="w-4 h-4" />
|
||||
{item.name}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
<div className="ml-2 pl-4 border-l border-border flex items-center gap-1.5">
|
||||
<div className="flex min-w-0 flex-1 items-center justify-end gap-3">
|
||||
<nav className="flex min-w-0 flex-1 items-center gap-1 overflow-x-auto whitespace-nowrap [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
|
||||
{NAV_ITEMS.map((item) => {
|
||||
const isActive =
|
||||
item.href === '/'
|
||||
? pathname === '/'
|
||||
: pathname.startsWith(item.href);
|
||||
const Icon = item.icon;
|
||||
return (
|
||||
<Link
|
||||
key={item.href}
|
||||
href={item.href}
|
||||
className={`flex shrink-0 items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition-colors ${
|
||||
isActive
|
||||
? 'bg-primary text-primary-foreground'
|
||||
: 'text-muted-foreground hover:bg-accent hover:text-accent-foreground'
|
||||
}`}
|
||||
>
|
||||
<Icon className="w-4 h-4" />
|
||||
{item.name}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
|
||||
<div className="flex shrink-0 items-center gap-1.5 border-l border-border pl-4">
|
||||
{user ? (
|
||||
<>
|
||||
<div className="flex items-center gap-1.5 px-3.5 py-2 rounded-md text-sm font-medium text-foreground">
|
||||
<div className="flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium text-foreground">
|
||||
<UserCircle2 className="w-4 h-4" />
|
||||
<span className="max-w-32 truncate">{user.username}</span>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleLogout}
|
||||
className="flex items-center gap-1.5 px-3.5 py-2 rounded-md text-sm font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground"
|
||||
className="flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground"
|
||||
>
|
||||
<LogOut className="w-4 h-4" />
|
||||
退出登录
|
||||
@ -128,7 +140,7 @@ const Header = () => {
|
||||
<Link
|
||||
key={item.href}
|
||||
href={item.href}
|
||||
className={`flex items-center gap-1.5 px-3.5 py-2 rounded-md text-sm font-medium transition-colors ${
|
||||
className={`flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition-colors ${
|
||||
isActive
|
||||
? 'bg-primary text-primary-foreground'
|
||||
: 'text-muted-foreground hover:bg-accent hover:text-accent-foreground'
|
||||
@ -141,10 +153,11 @@ const Header = () => {
|
||||
})
|
||||
) : null}
|
||||
</div>
|
||||
<div className="ml-4 pl-4 border-l border-border">
|
||||
|
||||
<div className="shrink-0 border-l border-border pl-4">
|
||||
<ConnectionDot />
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@ -125,7 +125,7 @@ export function MessageList({
|
||||
{messages.length === 0 && !isThinking && (
|
||||
<div className="flex flex-col items-center justify-center py-20 text-muted-foreground">
|
||||
<Bot className="w-12 h-12 mb-4 opacity-50" />
|
||||
<p className="text-lg font-medium">Boardware Genius</p>
|
||||
<p className="text-lg font-medium">Boardware Agent Sandbox</p>
|
||||
<p className="text-sm">发送消息开始对话</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@ -543,6 +543,7 @@ export async function addCronJob(params: {
|
||||
every_seconds?: number;
|
||||
cron_expr?: string;
|
||||
at_iso?: string;
|
||||
session_key?: string;
|
||||
}): Promise<CronJob> {
|
||||
return fetchJSON('/api/cron/jobs', {
|
||||
method: 'POST',
|
||||
|
||||
67
app-instance/frontend/public/boardware-logo.svg
Normal file
67
app-instance/frontend/public/boardware-logo.svg
Normal file
@ -0,0 +1,67 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 320" role="img" aria-labelledby="title desc">
|
||||
<title id="title">BoardWare logo</title>
|
||||
<desc id="desc">A triangular BoardWare mark in blue and red with the word BoardWare above it.</desc>
|
||||
<defs>
|
||||
<linearGradient id="blueTop" x1="0%" y1="0%" x2="0%" y2="100%">
|
||||
<stop offset="0%" stop-color="#142f58" />
|
||||
<stop offset="100%" stop-color="#163a70" />
|
||||
</linearGradient>
|
||||
<linearGradient id="blueMid" x1="0%" y1="0%" x2="0%" y2="100%">
|
||||
<stop offset="0%" stop-color="#2c5f9f" />
|
||||
<stop offset="100%" stop-color="#4c89d0" />
|
||||
</linearGradient>
|
||||
<linearGradient id="blueBottom" x1="0%" y1="0%" x2="0%" y2="100%">
|
||||
<stop offset="0%" stop-color="#5d95da" />
|
||||
<stop offset="100%" stop-color="#2f63af" />
|
||||
</linearGradient>
|
||||
<linearGradient id="redTop" x1="0%" y1="0%" x2="0%" y2="100%">
|
||||
<stop offset="0%" stop-color="#421216" />
|
||||
<stop offset="100%" stop-color="#70161d" />
|
||||
</linearGradient>
|
||||
<linearGradient id="redMid" x1="0%" y1="0%" x2="0%" y2="100%">
|
||||
<stop offset="0%" stop-color="#7a161c" />
|
||||
<stop offset="100%" stop-color="#932127" />
|
||||
</linearGradient>
|
||||
<linearGradient id="redBottom" x1="0%" y1="0%" x2="0%" y2="100%">
|
||||
<stop offset="0%" stop-color="#8a1f23" />
|
||||
<stop offset="100%" stop-color="#631116" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
|
||||
<text
|
||||
x="26"
|
||||
y="46"
|
||||
transform="rotate(10 26 46)"
|
||||
fill="#2a3a55"
|
||||
font-family="Georgia, Times New Roman, serif"
|
||||
font-size="24"
|
||||
font-style="italic"
|
||||
font-weight="600"
|
||||
letter-spacing="0.5"
|
||||
>
|
||||
BoardWare
|
||||
</text>
|
||||
|
||||
<polygon points="20,58 67,64 47,126" fill="url(#blueTop)" />
|
||||
<polygon points="74,65 120,71 101,133" fill="url(#blueTop)" />
|
||||
<polygon points="127,71 172,77 154,138" fill="url(#blueTop)" />
|
||||
<polygon points="180,78 224,84 206,145" fill="url(#blueTop)" />
|
||||
|
||||
<polygon points="50,135 88,141 72,191" fill="url(#blueMid)" />
|
||||
<polygon points="123,144 160,149 143,199" fill="url(#blueMid)" />
|
||||
<polygon points="85,211 122,216 105,268" fill="url(#blueMid)" />
|
||||
<polygon points="139,219 176,224 159,276" fill="url(#blueBottom)" />
|
||||
<polygon points="170,224 209,229 191,283" fill="url(#blueBottom)" />
|
||||
<polygon points="138,283 191,283 165,320" fill="url(#blueBottom)" />
|
||||
|
||||
<polygon points="224,84 246,90 210,148" fill="url(#redTop)" />
|
||||
<polygon points="249,91 270,97 230,154" fill="url(#redTop)" />
|
||||
<polygon points="273,98 294,104 249,161" fill="url(#redTop)" />
|
||||
<polygon points="297,105 314,111 267,168" fill="url(#redTop)" />
|
||||
|
||||
<polygon points="211,148 230,154 203,207" fill="url(#redMid)" />
|
||||
<polygon points="233,155 251,160 220,213" fill="url(#redMid)" />
|
||||
<polygon points="204,207 221,213 194,265" fill="url(#redBottom)" />
|
||||
<polygon points="223,214 240,219 208,270" fill="url(#redBottom)" />
|
||||
<polygon points="191,283 208,270 165,320" fill="url(#redBottom)" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.9 KiB |
@ -615,6 +615,14 @@ export interface ChatThinkingEvent {
|
||||
status: string;
|
||||
}
|
||||
|
||||
export interface SessionUpdatedEvent {
|
||||
type: 'session_updated';
|
||||
session_id: string;
|
||||
source?: string;
|
||||
job_id?: string;
|
||||
job_name?: string;
|
||||
}
|
||||
|
||||
export type ProcessWsEvent =
|
||||
| ProcessRunStartedEvent
|
||||
| ProcessRunProgressEvent
|
||||
@ -624,4 +632,4 @@ export type ProcessWsEvent =
|
||||
| ProcessRunCancelledEvent
|
||||
| ProcessCancelAckEvent;
|
||||
|
||||
export type WsEvent = ChatAssistantEvent | ChatThinkingEvent | ProcessWsEvent;
|
||||
export type WsEvent = ChatAssistantEvent | ChatThinkingEvent | SessionUpdatedEvent | ProcessWsEvent;
|
||||
|
||||
Reference in New Issue
Block a user