Files
proxycast/package.json
T
cosoandClaude Opus 4.6 b14dbe8271 feat: 实现 Agent 调度器系统
实现完整的 Agent 任务调度系统,支持定时任务、批量处理和后台持续运行。

## 新增功能

### 1. proxycast-scheduler Crate
- 创建独立的调度器 crate
- 实现 SchedulerTrait 接口
- 支持任务 CRUD 操作
- 任务持久化到 SQLite

### 2. 数据模型
- ScheduledTask: 调度任务结构
- TaskStatus: 任务状态枚举 (Pending, Running, Completed, Failed, Cancelled)
- TaskFilter: 任务查询过滤器

### 3. AgentScheduler
- 实现调度器核心逻辑
- 支持任务创建、查询、更新、删除
- 支持到期任务查询
- 自动状态管理

### 4. AgentExecutor
- 实现任务执行器
- 通过 CredentialBridge 自动选择凭证
- 支持多种任务类型:
  - agent_chat: Agent 对话任务
  - batch_process: 批量处理任务
  - scheduled_report: 定时报告任务
- 自动标记凭证健康状态

### 5. SchedulerService (Heartbeat Loop)
- 实现心跳循环服务
- 每 30 秒轮询到期任务
- 自动执行到期任务
- 支持优雅启动和关闭 (CancellationToken)
- 集成到 Tauri setup

### 6. 数据库集成
- 创建 scheduled_tasks 表
- 添加索引 (status, scheduled_at, provider_type)
- 自动初始化表结构

## 技术实现

- 使用 tokio::spawn 启动后台任务
- 使用 tokio::time::interval 实现定时轮询
- 使用 tokio::select! 监听取消信号
- 完整的错误处理和日志记录
- 所有模块包含单元测试

## 文件清单

新增:
- src-tauri/crates/scheduler/Cargo.toml
- src-tauri/crates/scheduler/src/lib.rs
- src-tauri/crates/scheduler/src/types.rs
- src-tauri/crates/scheduler/src/dao.rs
- src-tauri/crates/scheduler/src/scheduler.rs
- src-tauri/crates/scheduler/src/executor.rs
- src-tauri/src/app/scheduler_service.rs

修改:
- src-tauri/Cargo.toml (添加 scheduler 依赖)
- src-tauri/src/app/mod.rs (导出 scheduler_service)
- src-tauri/src/app/setup.rs (集成调度器服务)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-09 21:47:52 +08:00

125 lines
4.1 KiB
JSON

{
"name": "proxycast",
"private": true,
"version": "0.61.0",
"type": "module",
"repository": {
"type": "git",
"url": "https://github.com/aiclientproxy/proxycast.git"
},
"homepage": "https://github.com/aiclientproxy/proxycast",
"scripts": {
"dev": "npx vite",
"build": "tsc && vite build",
"preview": "vite preview",
"tauri": "tauri",
"tauri:dev:headless": "tauri dev --config src-tauri/tauri.conf.headless.json",
"lint": "eslint src --max-warnings 0",
"format": "prettier --write \"src/**/*.{ts,tsx,css}\"",
"prepare": "husky",
"test": "vitest --run",
"test:watch": "vitest",
"detect-translations": "tsx scripts/detect-missing-translations.ts",
"detect-translations:fix": "tsx scripts/detect-missing-translations.ts --fix",
"detect-translations:verbose": "tsx scripts/detect-missing-translations.ts --verbose"
},
"dependencies": {
"@babel/standalone": "^7.29.0",
"@fabianlars/tauri-plugin-oauth": "^2",
"@floating-ui/react": "^0.27.16",
"@observablehq/plot": "^0.6.17",
"@radix-ui/react-collapsible": "^1.1.12",
"@radix-ui/react-context-menu": "^2.2.16",
"@radix-ui/react-dialog": "^1.1.2",
"@radix-ui/react-dropdown-menu": "^2.1.2",
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-popover": "^1.1.15",
"@radix-ui/react-select": "^2.1.2",
"@radix-ui/react-slider": "^1.3.6",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-switch": "^1.1.1",
"@radix-ui/react-tabs": "^1.1.1",
"@radix-ui/react-toast": "^1.2.2",
"@radix-ui/react-tooltip": "^1.1.3",
"@tanstack/react-virtual": "^3.13.18",
"@tauri-apps/api": "2.10.1",
"@tauri-apps/plugin-deep-link": "2.4.6",
"@tauri-apps/plugin-dialog": "2.6.0",
"@tauri-apps/plugin-global-shortcut": "2.3.1",
"@tauri-apps/plugin-shell": "2.3.4",
"@tiptap/extension-placeholder": "^3.18.0",
"@tiptap/pm": "^3.18.0",
"@tiptap/react": "^3.18.0",
"@tiptap/starter-kit": "^3.18.0",
"@tonejs/midi": "^2.0.28",
"@types/lodash-es": "^4.17.12",
"@types/styled-components": "^5.1.36",
"@xterm/addon-fit": "^0.11.0",
"@xterm/addon-search": "^0.16.0",
"@xterm/addon-unicode11": "^0.9.0",
"@xterm/addon-web-links": "^0.12.0",
"@xterm/addon-webgl": "^0.19.0",
"@xterm/xterm": "^6.0.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"cmdk": "^1.1.1",
"date-fns": "^4.1.0",
"dayjs": "^1.11.19",
"fabric": "^5.5.2",
"hast-util-to-html": "^9.0.5",
"i18next": "^25.7.3",
"jotai": "^2.16.1",
"lodash-es": "^4.17.22",
"lucide-react": "^0.460.0",
"mermaid": "^11.12.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-i18next": "^16.5.1",
"react-markdown": "^10.1.0",
"react-resizable-panels": "^4.3.0",
"react-router-dom": "^7.11.0",
"react-syntax-highlighter": "^16.1.0",
"refractor": "^5.0.0",
"rehype-katex": "^7.0.1",
"rehype-raw": "^7.0.0",
"remark-gfm": "^4.0.1",
"remark-math": "^6.0.0",
"sonner": "^2.0.7",
"styled-components": "^6.1.19",
"tailwind-merge": "^2.6.0",
"tone": "^15.1.22",
"zustand": "^5.0.10"
},
"devDependencies": {
"@babel/plugin-transform-react-jsx-source": "^7.27.1",
"@eslint/js": "^9.15.0",
"@fast-check/vitest": "^0.2.4",
"@tauri-apps/cli": "^2.0.0",
"@types/babel__standalone": "^7.1.9",
"@types/fabric": "^5.3.11",
"@types/node": "^22.9.0",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@types/react-syntax-highlighter": "^15.5.13",
"@typescript-eslint/eslint-plugin": "^8.15.0",
"@typescript-eslint/parser": "^8.15.0",
"@vitejs/plugin-react": "^4.3.3",
"autoprefixer": "^10.4.20",
"eslint": "^9.15.0",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "^0.4.14",
"fast-check": "^4.4.0",
"globals": "^15.12.0",
"husky": "^9.1.7",
"jsdom": "^22.1.0",
"postcss": "^8.4.47",
"prettier": "^3.3.3",
"tailwindcss": "^3.4.14",
"tsx": "^4.21.0",
"typescript": "^5.6.3",
"vite": "^5.4.21",
"vite-plugin-svgr": "^4.5.0",
"vitest": "^3.2.4"
}
}