Refine knowledge brain workflow

Align the brain prompts, graph view, and startup defaults with the
latest phase 1 flow so local runs and navigation stay consistent.
This commit is contained in:
2026-03-22 22:42:47 +08:00
parent 67ea3d2682
commit 6f594631e9
23 changed files with 1508 additions and 526 deletions

View File

@@ -1 +1 @@
VITE_API_URL=http://localhost:9528
VITE_API_URL=http://127.0.0.1:3337

View File

@@ -0,0 +1,38 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { createPinia, setActivePinia } from 'pinia'
const { apiGetMock } = vi.hoisted(() => ({
apiGetMock: vi.fn(),
}))
vi.mock('@/api', () => ({
default: {
get: apiGetMock,
post: vi.fn(),
interceptors: {
request: { use: vi.fn() },
response: { use: vi.fn() },
},
},
}))
describe('auth router guard', () => {
beforeEach(() => {
vi.resetModules()
localStorage.clear()
apiGetMock.mockReset()
window.history.replaceState({}, '', '/')
setActivePinia(createPinia())
})
it('redirects to /login when a stored token fails validation during startup', async () => {
localStorage.setItem('access_token', 'stale-token')
apiGetMock.mockRejectedValueOnce({ response: { status: 401 } })
const { default: router } = await import('./index')
await router.push('/chat')
expect(router.currentRoute.value.fullPath).toBe('/login')
})
})

View File

@@ -7,8 +7,11 @@ const router = createRouter({
routes,
})
router.beforeEach((to, _from, next) => {
router.beforeEach(async (to, _from, next) => {
const auth = useAuthStore()
await auth.ensureAuthReady()
if (to.meta.requiresAuth && !auth.isAuthenticated) {
next('/login')
} else if (to.meta.guest && auth.isAuthenticated) {

File diff suppressed because it is too large Load Diff

View File

@@ -13,47 +13,47 @@ export const DEFAULT_AGENTS: Agent[] = [
{
id: 'master',
name: 'JARVIS',
role: '指挥官',
role: '战略中枢',
roleKey: 'master',
description: '中央指挥官,协调所有子 Agent 工作,理解用户意图并分配任务',
systemPrompt: '你是 Jarvis 的主控制核心。你的职责是理解用户的请求,协调规划、执行、知识官、分析师四个子 Agent 工作。分析请求,决定调用哪个子 Agent将任务分发并汇总结果反馈给用户。',
description: '负责理解目标、判断路径并协调各子 Agent 推进,不是普通助手,而是整体协作的中枢',
systemPrompt: '你是 Jarvis 的战略中枢。你的职责不是机械分发任务,而是先看清用户真正要解决的问题,再协调规划、执行、知识与分析能力,把复杂度压平,并给出清晰、可推进的回应。',
enabled: true,
isMaster: true,
},
{
id: 'planner',
name: 'PLANNER',
role: '规划',
role: '路径规划',
roleKey: 'planner',
description: '制定任务计划,拆解复杂目标为可执行步骤,规划执行顺序',
systemPrompt: '你是规划专家。当用户提出需要规划的任务时,将目标拆解为清晰可执行的步骤列表。为每个步骤标注优先级和预计时间,帮助用户理解任务的全貌。',
description: '负责拆解复杂目标、安排顺序、收束执行路径,让事情变得清楚可做',
systemPrompt: '你是 Jarvis 的路径规划师。面对复杂目标时,先识别约束和优先级,再把任务拆成清晰可执行的步骤,帮助用户迅速看清最短可行路径。',
enabled: true,
},
{
id: 'executor',
name: 'EXECUTOR',
role: '执行者',
role: '执行推进者',
roleKey: 'executor',
description: '调用工具执行具体操作,创建/更新/删除系统资源',
systemPrompt: '你是执行专家。根据规划者的计划,调用相应工具执行具体操作。包括创建文档、创建任务、发送消息、管理日程等操作。执行完成后汇报结果。',
description: '负责调用工具落实具体操作,关注结果、边界和下一步,而不是只回报动作',
systemPrompt: '你是 Jarvis 的执行推进者。根据当前目标调用工具完成具体操作,明确说明已经做了什么、结果如何、还差什么,并把下一步交代清楚。',
enabled: true,
},
{
id: 'librarian',
name: 'LIBRARIAN',
role: '知识',
role: '知识统筹者',
roleKey: 'librarian',
description: '管理知识库和知识图谱,检索相关信息,更新记忆',
systemPrompt: '你是知识管理员。负责管理用户的知识库、文档库和知识图谱。当用户需要搜索信息、添加知识、整理记忆时介入。保持知识的准确性和关联性。',
description: '负责检索、连接和梳理知识,让信息不只是被找到,而是被理解和利用',
systemPrompt: '你是 Jarvis 的知识统筹者。你的职责是检索用户的知识库与相关上下文,提炼重点、连接线索,并在证据范围内给出可靠回答。',
enabled: true,
},
{
id: 'analyst',
name: 'ANALYST',
role: '分析师',
role: '洞察分析师',
roleKey: 'analyst',
description: '分析工作数据,生成统计报告,提供洞察建议',
systemPrompt: '你是数据分析师。当用户需要分析、统计、总结数据时介入。查询系统数据,生成可读性强的报告,用数据支持决策。',
description: '负责从数据和状态里提炼趋势、风险与判断,支持更高质量的决策',
systemPrompt: '你是 Jarvis 的洞察分析师。当用户需要分析、统计、总结或判断趋势时,你要从数据里提炼真正有用的结论,并给出可执行的判断与建议。',
enabled: true,
},
]

View File

@@ -291,8 +291,8 @@ function renderMarkdown(content: string) {
</div>
</div>
<div class="welcome-title">JARVIS</div>
<div class="welcome-sub">Personal AI Assistant</div>
<div class="welcome-hint">有什么我可以帮你的</div>
<div class="welcome-sub">Strategic Thinking Partner</div>
<div class="welcome-hint">把目标给我我先帮您收束重点再往下推进</div>
</div>
<!-- Message bubbles -->

View File

@@ -1,8 +1,11 @@
import { defineConfig } from 'vite'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
export default defineConfig({
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, __dirname, '')
return {
plugins: [vue()],
resolve: {
alias: {
@@ -12,9 +15,10 @@ export default defineConfig({
server: {
proxy: {
'/api': {
target: 'http://localhost:9527',
target: env.VITE_API_URL,
changeOrigin: true,
},
},
},
}
})