* ✨ 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>
* 🗃️ chore: add agent task system database schema
Add 6 new tables for the Agent Task System:
- tasks: core task with tree structure, heartbeat, scheduling
- task_dependencies: inter-task dependency graph (blocks/relates)
- task_documents: MVP workspace document pinning
- task_topics: topic tracking with handoff (jsonb) and review results
- task_comments: user/agent comments with author tracking (text id: cmt_)
- briefs: unresolved notification system (text id: brf_)
All sub-tables include userId FK for row-level user isolation.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* 🗃️ chore: add self-referential FK on tasks.parentTaskId (ON DELETE SET NULL)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* 🐛 fix: use foreignKey() for self-referential parentTaskId to avoid TS circular inference
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* 🗃️ chore: add FK on task_topics.topic_id → topics.id (ON DELETE SET NULL)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* 🐛 fix: resolve pre-existing TS type-check errors
- Fix i18next defaultValue type (string | null → string)
- Fix i18next options type mismatches
- Fix fieldTags.webhook possibly undefined
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* 🗃️ chore: add FK on tasks.currentTopicId → topics.id (ON DELETE SET NULL)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* 🗃️ chore: add FK constraints for assignee, author, topic, and parent fields
- tasks.assigneeUserId → users.id (ON DELETE SET NULL)
- tasks.assigneeAgentId → agents.id (ON DELETE SET NULL)
- tasks.parentTaskId → tasks.id (ON DELETE SET NULL)
- tasks.currentTopicId → topics.id (ON DELETE SET NULL)
- task_comments.authorUserId → users.id (ON DELETE SET NULL)
- task_comments.authorAgentId → agents.id (ON DELETE SET NULL)
- task_topics.topicId → topics.id (ON DELETE SET NULL)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* 🗃️ chore: change task_topics.topicId FK to ON DELETE CASCADE
Topic deleted → task_topic mapping row removed (not just nulled).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* ♻️ refactor: use inline .references() for currentTopicId FK
No circular inference issue — only parentTaskId (self-ref) needs foreignKey().
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* 🗃️ chore: add FK on task_comments.briefId and topicId (ON DELETE SET NULL)
- task_comments.briefId → briefs.id (SET NULL)
- task_comments.topicId → topics.id (SET NULL)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* ♻️ refactor: merge briefs table into task.ts to fix circular dependency
brief.ts imported task.ts (briefs.taskId FK) and task.ts imported
brief.ts (taskComments.briefId FK), causing circular dependency error.
Merged briefs into task.ts since briefs are part of the task system.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* 🗃️ chore: add FK on tasks.createdByAgentId → agents.id (ON DELETE SET NULL)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* 🔨 chore(database): added id_nanoid to replace id using seq and identity
* 🔨 chore(database): assgin database id column value to id_nanoid
* 🔨 chore(database): update dbml
* 🔨 chore(database): add not null & unique index
* 🔨 chore(database): drop foreign key dependency, switch to depend on id_nanoid
* 🔨 chore(database): switch to use id_nanoid as primary key
* 🔨 chore(database): drop old id column
* 🔨 chore(database): rename id_nanoid to id
* 🔨 chore(database): remove unique constraint
* 🔨 chore(database): updated dbml
* 🔨 chore(database): incorrect --> statement-breakpoint
* feat: generate agent_cron_job in agents
* feat: update the db fields
* feat: add trigger/mode in topics table & add group id in cronjob
* feat: update sql
* fix: fixed db migration
* feat: update the test
* Refactor code structure for improved readability and maintainability
* edit dbml
* feat: 更新 AiInfraRepos 以支持用户设置覆盖内置设置
* Revert "Refactor code structure for improved readability and maintainability"
This reverts commit 81453d8dc3.
* Refactor code structure for improved readability and maintainability
* 添加 IF NOT EXISTS 选项以避免重复列添加
* format