feat(engine): 优化智能体循环中的助手消息处理逻辑

- 在没有工具调用时才添加助手消息到上下文
- 确保工具调用响应正确添加到消息上下文中
- 修复了消息构建的条件逻辑

fix(cron): 改进定时任务调度的时间解析功能

- 添加正则表达式导入用于时间显示解析
- 实现从显示文本中提取毫秒间隔的功能
- 增强整数转换的安全性,避免类型错误
- 优化定时任务配置的解析逻辑

feat(outlook): 增强Outlook集成的功能和稳定性

- 将默认超时时间从10秒增加到180秒
- 为状态检查函数添加可选的验证参数
- 串行执行邮件概览获取操作而非并行
- 改进连接状态验证逻辑

feat(channel): 添加设备名称作为会话标识的选项

- 为终端WebSocket适配器添加新的配置选项
- 实现基于设备名称生成会话对等ID的功能
- 记录原始对等ID和设备名称的元数据
- 支持从设备名称创建会话对等ID

feat(skills): 完善技能学习评估系统和进度跟踪

- 在应用启动时自动调度待评估的技能草稿
- 为技能评估工作创建独立的循环工厂
- 实现异步技能评估任务的取消和清理机制
- 添加技能评估进度报告和状态跟踪功能
- 扩展会话列表API以包含更多详细信息
- 防止对不存在的会话进行操作
- 优化技能草稿提交和评估的业务逻辑

perf(skills): 提升技能评估的并发性能

- 实现并行技能案例评估以提高效率
- 添加最大并行案例数的环境变量控制
- 实现实时评估进度更新和回调机制
- 优化评估过程中的资源管理和同步

refactor(services): 创建隔离的智能体循环实例

- 添加创建独立智能体循环的工厂方法
- 确保新循环继承运行时服务配置
- 支持技能评估等需要隔离环境的场景
```
This commit is contained in:
2026-06-15 14:48:16 +08:00
parent 8aeb97a5fc
commit 4b0bf65ace
53 changed files with 4328 additions and 292 deletions

View File

@ -60,7 +60,7 @@ const ACCESS_TOKEN_KEY = 'beaver_access_token';
const REFRESH_TOKEN_KEY = 'beaver_refresh_token';
export const AUTH_CLEARED_EVENT = 'beaver-auth-cleared';
const REQUEST_TIMEOUT_MS = 8000;
const OUTLOOK_REQUEST_TIMEOUT_MS = 45000;
const OUTLOOK_REQUEST_TIMEOUT_MS = 360000;
const SKILL_LEARNING_REQUEST_TIMEOUT_MS = 120000;
export type PromptLocale = 'zh-Hans' | 'zh-Hant' | 'en';
@ -902,10 +902,11 @@ export async function submitSkillDraft(
skillName: string,
draftId: string,
notes: string = ''
): Promise<SkillReviewRecord> {
): Promise<SkillDraft> {
return fetchJSON(`/api/skills/${encodeURIComponent(skillName)}/drafts/${encodeURIComponent(draftId)}/submit`, {
method: 'POST',
body: JSON.stringify({ notes }),
timeoutMs: SKILL_LEARNING_REQUEST_TIMEOUT_MS,
});
}

View File

@ -0,0 +1,28 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import {
NOTIFICATION_REFRESH_INTERVAL_MS,
scheduleNotificationRefresh,
} from '@/lib/notification-runtime';
describe('notification refresh scheduling', () => {
beforeEach(() => {
vi.useFakeTimers();
});
afterEach(() => {
vi.useRealTimers();
});
it('refreshes notifications periodically until cleanup', async () => {
const refresh = vi.fn();
const cleanup = scheduleNotificationRefresh(refresh);
await vi.advanceTimersByTimeAsync(NOTIFICATION_REFRESH_INTERVAL_MS);
expect(refresh).toHaveBeenCalledTimes(1);
cleanup();
await vi.advanceTimersByTimeAsync(NOTIFICATION_REFRESH_INTERVAL_MS);
expect(refresh).toHaveBeenCalledTimes(1);
});
});

View File

@ -0,0 +1,12 @@
export const NOTIFICATION_REFRESH_INTERVAL_MS = 5_000;
export function scheduleNotificationRefresh(
refresh: () => void | Promise<void>,
intervalMs = NOTIFICATION_REFRESH_INTERVAL_MS,
): () => void {
const timer = setInterval(() => {
void refresh();
}, intervalMs);
return () => clearInterval(timer);
}

View File

@ -0,0 +1,16 @@
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
import { describe, expect, it } from 'vitest';
describe('Outlook count presentation', () => {
it('does not render summary count chips or tab count labels', () => {
const source = readFileSync(
resolve(process.cwd(), 'app/(app)/outlook/page.tsx'),
'utf8',
);
expect(source).not.toContain('<TopStat');
expect(source).not.toContain('view.count');
});
});

View File

@ -0,0 +1,29 @@
import { describe, expect, it } from 'vitest';
import { nextOutlookAutoLoadTarget } from '@/lib/outlook-page-state';
describe('nextOutlookAutoLoadTarget', () => {
it('loads the active mailbox once when it has not been attempted', () => {
expect(
nextOutlookAutoLoadTarget({
isConfigured: true,
activeView: 'inbox',
loaded: { inbox: false, sent: false, calendar: false },
loading: { inbox: false, sent: false, calendar: false },
attempted: { inbox: false, sent: false, calendar: false },
})
).toBe('inbox');
});
it('does not auto-retry the same mailbox after a failed attempt', () => {
expect(
nextOutlookAutoLoadTarget({
isConfigured: true,
activeView: 'inbox',
loaded: { inbox: false, sent: false, calendar: false },
loading: { inbox: false, sent: false, calendar: false },
attempted: { inbox: true, sent: false, calendar: false },
})
).toBeNull();
});
});

View File

@ -0,0 +1,20 @@
export type OutlookAutoLoadView = 'inbox' | 'sent' | 'calendar';
export interface OutlookAutoLoadState {
isConfigured: boolean;
activeView: OutlookAutoLoadView | 'settings';
loaded: Record<OutlookAutoLoadView, boolean>;
loading: Record<OutlookAutoLoadView, boolean>;
attempted: Record<OutlookAutoLoadView, boolean>;
}
export function nextOutlookAutoLoadTarget(state: OutlookAutoLoadState): OutlookAutoLoadView | null {
if (!state.isConfigured || state.activeView === 'settings') {
return null;
}
const view = state.activeView;
if (state.loaded[view] || state.loading[view] || state.attempted[view]) {
return null;
}
return view;
}