Commit Graph

22 Commits

Author SHA1 Message Date
Arvin Xu
093fa7bcae feat: support agent tasks system (#13289)
*  feat: agent task system — CLI, review rubrics, workspace, comments, brief tool split

support import md

Major changes:
- Split task CLI into modular files (task/, lifecycle, topic, doc, review, checkpoint, dep)
- Split builtin-tool-task into task + brief tools (conditional injection)
- Task review uses EvalBenchmarkRubric from @lobechat/eval-rubric
- Task workspace: documents auto-pin via Notebook, tree view with folders
- Task comments system (task_comments table)
- Task topics: dedicated TaskTopicModel with userId, handoff fields, review results
- Heartbeat timeout auto-detection in detail API
- Run idempotency (reject duplicate runs) + error rollback
- Topic cancel/delete by topicId only (no taskId needed)
- Integration tests for task router (13 tests)
- interruptOperation fix (string param, not object)
- Global TRPC error handler in CLI

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

task document workflow

task handoff loop

🗃️ chore: consolidate task system migrations into single 0095

Merged 7 separate migrations (0095-0101) into one:
- tasks, briefs, task_comments, task_dependencies, task_documents, task_topics tables
- All fields including sort_order, resolved_action/comment, review fields
- Idempotent CREATE TABLE IF NOT EXISTS, DROP/ADD CONSTRAINT, CREATE INDEX IF NOT EXISTS

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

fix interruptOperation

topic auto review workflow

topic handoff workflow

finish run topic and brief workflow

support task tool

improve task schema

update

 feat: add onComplete hook to task.run for completion callbacks

When agent execution completes, the hook:
- Updates task heartbeat
- Creates a result Brief (on success) with assistant content summary
- Creates an error Brief (on failure) with error message
- Supports both local (handler) and production (webhook) modes

Uses the new Agent Runtime Hooks system instead of raw stepCallbacks.

LOBE-6160 LOBE-6208

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

 feat: add Review system — LLM-as-Judge automated review

Task review uses an independent LLM call to evaluate topic output
quality against configurable criteria with pass/fail thresholds.

- TaskReviewService: structured LLM review via generateObject,
  auto-resolves model/provider from user's system agent defaults
- Model: getReviewConfig, updateReviewConfig on TaskModel
- Router: getReview, updateReview, runReview procedures
- CLI: `task review set/view/run` commands
- Auto-creates Brief with review results

LOBE-6165

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

 feat: add TaskScheduler, multi-topic execution, and handoff context

- TaskScheduler: interface + Local implementation (setTimeout-based),
  following QueueService dual-mode pattern
- Multi-topic execution: `task run --topics N --delay S` runs N topics
  in sequence with optional delay between them
- Handoff context: buildTaskPrompt() queries previous topics by
  metadata.taskId and injects handoff summaries into the next topic's
  prompt (sliding window: latest full, older summaries only)
- Heartbeat auto-update between topics

LOBE-6161

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

 feat: add Heartbeat watchdog + heartbeat CLI

Watchdog scans running tasks with expired heartbeats, marks them as
failed, and creates urgent error Briefs. Heartbeat CLI allows manual
heartbeat reporting for testing.

- Model: refactored to use Drizzle operators (isNull, isNotNull, ne)
  instead of raw SQL where possible; fixed findStuckTasks to skip
  tasks without heartbeat data
- Router: heartbeat (manual report), watchdog (scan + fail + brief)
- Router: updateSchema now includes heartbeatInterval, heartbeatTimeout
- CLI: `task heartbeat <id>`, `task watchdog`, `task edit` with
  --heartbeat-timeout, --heartbeat-interval, --description

LOBE-6161

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

♻️ refactor: move CheckpointConfig to @lobechat/types

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

 feat: add task run — trigger agent execution for tasks

Task.run creates a topic, triggers AiAgentService.execAgent with task
context, and streams results via SSE. Supports both agentId and slug.

- Service: added taskId to ExecAgentParams, included in topic metadata
- Router: task.run procedure — resolves agent, builds prompt, calls execAgent,
  updates topic count and heartbeat
- CLI: `task run <id>` command with SSE streaming, --prompt, --verbose

LOBE-6160

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

 feat: add Checkpoint system for task review gates

Checkpoint allows configuring pause points in task execution flow.
Supports beforeIds (pause before subtask starts) and afterIds (pause
after subtask completes) on parent tasks.

- Model: CheckpointConfig type, getCheckpointConfig, updateCheckpointConfig,
  shouldPauseBeforeStart, shouldPauseAfterComplete
- Router: getCheckpoint, updateCheckpoint procedures; integrated with
  updateStatus for automatic checkpoint triggering
- CLI: `task checkpoint view/set` commands with --before, --after,
  --topic-before, --topic-after, --on-agent-request options
- Tests: 3 new checkpoint tests (37 total)

LOBE-6162

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

 feat: add dependency unlocking on task completion

When a task completes, automatically check and unlock blocked tasks
whose dependencies are all satisfied (backlog → running). Also notify
when all subtasks of a parent are completed.

- Model: getUnlockedTasks, areAllSubtasksCompleted (Drizzle, no raw SQL)
- Router: updateStatus hook triggers unlocking on completion
- CLI: shows unlocked tasks and parent completion notification
- Tests: 3 new tests (34 total)

LOBE-6164

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

 feat: add Brief system — schema, model, router, CLI

Brief is a universal Agent-to-User reporting mechanism, not limited to
Tasks. CronJobs, Agents, and future systems can all produce Briefs.

- Schema: briefs table with polymorphic source (taskId, cronJobId, agentId)
- Model: BriefModel with CRUD, listUnresolved (Daily Brief), markRead, resolve
- Router: TRPC brief router with taskId identifier resolution
- CLI: `lh brief` command (list/view/read/resolve)
- Tests: 11 model tests
- Migration: 0096_add_briefs_table.sql

LOBE-6163

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

 feat: add Task system — schema, model, router, CLI

Implement the foundational Task system for managing long-running,
multi-topic agent tasks with subtask trees and dependency chains.

- Schema: tasks, task_dependencies, task_documents tables
- Model: TaskModel with CRUD, tree queries, heartbeat, dependencies, document pinning
- Router: TRPC task router with identifier/id resolution
- CLI: `lh task` command (list/view/create/edit/delete/start/pause/resume/complete/cancel/tree/dep)
- Tests: 31 model tests
- Migration: 0095_add_task_tables.sql

LOBE-6036 LOBE-6054

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* update

* 🐛 fix: update brief model import path and add raw-md vitest plugin

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* 🐛 fix: eslint import sort in vitest config

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* 🐛 fix: brief ID validation, auto-review retry, and continueTopicId operationId

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* 🐛 fix: task integration tests — create test agent for FK, fix children spread

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* 🐛 fix: task integration tests — correct identifier prefix and agent ID

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* 🐛 fix: remove unused toolsActivatorRuntime import

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* 🐛 fix: create real topic in task integration tests to satisfy FK constraint

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* 🐛 fix: type errors in task prompt tests, handoff schema, and activity mapping

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* 🐛 fix: create real agent/topic/brief records in database model tests for FK constraints

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 17:43:51 +08:00
Innei
04ddb992d1 🐛 fix(desktop): add missing Stats and Creds tabs to Electron componentMap (#13243) 2026-03-25 16:27:37 +08:00
Arvin Xu
76a07d811b feat: init lobehub-cli (#12735)
* init cli project

* Potential fix for code scanning alert no. 184: Uncontrolled command line

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* update

* Potential fix for code scanning alert no. 185: Uncontrolled command line

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-03-06 11:42:29 +08:00
YuTengjing
6ecba929b7 🔨 chore: remove dead eslint disable comments for deleted rules (#12597) 2026-03-02 23:18:01 +08:00
YuTengjing
7df81ffaa1 🐛 fix: add sanitizeFileName alias to vitest config for test resolution 2026-02-15 20:32:24 +08:00
Innei
2b178010cc 🐛 fix: add markdownToTxt alias override in vitest config
The @/utils alias maps to packages/utils/src, but markdownToTxt lives
in src/utils. Add explicit alias to fix test resolution failures.
2026-02-11 13:05:16 +08:00
Innei
fcdaf9d814 🔧 chore: update eslint v2 configuration and suppressions (#12133)
* v2 init

* chore: update eslint suppressions and package dependencies

- Removed several eslint suppressions related to array sorting and reversing from eslint-suppressions.json to clean up the configuration.
- Updated @lobehub/lint package version from 2.0.0-beta.6 to 2.0.0-beta.7 in package.json for improvements and bug fixes.
- Made minor formatting adjustments in vitest.config.mts and various SKILL.md files for better readability and consistency.

Signed-off-by: Innei <tukon479@gmail.com>

* fix: clean up import statements and formatting

- Removed unnecessary whitespace in replaceComponentImports.ts for improved readability.
- Standardized import statements in contextEngineering.ts and createAgentExecutors.ts by adding missing spaces for consistency.

Signed-off-by: Innei <tukon479@gmail.com>

* chore: update eslint suppressions and clean up code formatting

* 🐛 fix: use vi.hoisted for mock variable initialization

Fix TDZ error in persona service test by using vi.hoisted() to ensure
mock variables are available when vi.mock factory runs.

---------

Signed-off-by: Innei <tukon479@gmail.com>
2026-02-11 13:04:48 +08:00
Innei
ae499c9ab9 feat: improve PageEditor header UX with DropdownMenu and i18n support (#11462)
*  feat: improve PageEditor header UX with DropdownMenu and i18n support

- Migrate Header from Dropdown to DropdownMenu component with checkbox support
- Add i18n for Ask Copilot item using common cmdk.askLobeAI key
- Replace BotIcon with Avatar using DEFAULT_INBOX_AVATAR
- Add hideWhenExpanded prop to ToggleRightPanelButton
- Conditionally show page info section only when lastUpdatedTime exists

* 🔧 chore: update @lobehub/ui dependency to version 4.18.0 in package.json

* feat: unify proxy setting style

Signed-off-by: Innei <tukon479@gmail.com>

* fix: test

Signed-off-by: Innei <tukon479@gmail.com>

* fix: test

Signed-off-by: Innei <tukon479@gmail.com>

---------

Signed-off-by: Innei <tukon479@gmail.com>
2026-01-13 18:25:28 +08:00
YuTengjing
98d477b22b 🐛 chore(ci): support tokenless codecov upload for fork PRs (#11354) 2026-01-08 23:59:07 +08:00
Arvin Xu
b4ba8bf454 🐛 fix: model runtime provider issue (#11314)
* fix

* upload

* update

* fix

* fix tests
2026-01-07 23:22:19 +08:00
YuTengjing
4fc03bbf66 feat(image): improve image generation with new models and bug fixes (#11311) 2026-01-07 19:16:24 +08:00
Neko Ayaka
8786628016 fix: duplicated alias of vitest config 2025-12-29 18:52:41 +08:00
arvinxx
dba1acf2b4 feat: support exec async sub agent task 2025-12-29 17:50:38 +08:00
Innei
da4eb9c1b1 🧪 fix: improve test infrastructure and mock configurations (#11028)
* 🧪 fix: improve test infrastructure and mock configurations

- Add vitest plugin to fix @lobehub/fluent-emoji style import issue
- Update antd-style mocks to preserve actual exports while mocking specific functions
- Switch from useClientDataSWR to useClientDataSWRWithSync in tests
- Add @/utils/identifier alias in vitest config
- Fix duplicate @lobehub/ui mock in ComfyUIForm test

* 🐛 fix: use recommended-legacy for ESLint 8 compatibility

The @next/eslint-plugin-next v16 changed to flat config format which is
incompatible with ESLint 8. Using recommended-legacy to maintain compatibility.
2025-12-29 16:54:06 +08:00
Arvin Xu
5cc9141b52 🔨 chore: update config (#10857)
chore update config
2025-12-19 23:13:22 +08:00
YuTengjing
4f7bc5acd2 🐛 fix: add SSRF protection (#10152) 2025-11-11 19:39:36 +08:00
René Wang
e568ce6f31 💄 style: Unzip file when uploading in knowledge base [LOB-500] (#9854)
* feat: Unzip file

* feat: Limit max file upload limit

* fix: Remove unused test

* opti: Update translation

* style: Adjust padding

* feat: Update translation

* fix: Test error

* fix: Test erro

* fix: Test

* fix: test error

* fix: Test

* feat: Rremove message
2025-10-27 10:25:50 +08:00
Rdmclin2
61bbd596f0 🔨 chore: mobile related server implementation pick from mobile app (#9691)
* server: sync from feat/mobile-app (exclude apps/mobile)

* Update package.json

* chore(mobile): update mobile router imports to use lambda

* chore(mobile): refactor mobile router

* chore: format tsconfig.json

* chore(mobile): simplify mobile router

---------

Co-authored-by: Arvin Xu <arvinx@foxmail.com>
Co-authored-by: Tsuki <976499226@qq.com>
2025-10-16 11:32:58 +07:00
Arvin Xu
8693d95e0d 🔨 chore: add e2e workflow (#9677)
* add e2e test

* Potential fix for code scanning alert no. 137: Workflow does not contain permissions

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* remove

* update

* fix tests

* add e2e

* update

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2025-10-14 13:32:52 +08:00
Arvin Xu
7fe17e4028 ♻️ refactor: refactor model runtime folder structure and add more tests (#9210)
* add test

* fix tests

* fix tests

* revert tests

* refactor model runtime folder

* refactor model runtime folder and remove @/libs/model-runtime

* fix lint

* move

* fix tests
2025-09-11 11:22:05 +08:00
Arvin Xu
f900f7ce4e test: add unit tests for @lobechat/prompts (#8967)
* add test and refactor

* update

* move

* fix test

* improve config

* refactor utils server import

* move

* refactor @/utils/server to @lobechat/utils/server

* improve config

* fix tests
2025-08-28 20:44:28 +08:00
YuTengjing
0efe28d122 feat(image): polish ai image (#8915) 2025-08-25 22:38:41 +08:00