lobehub/docs/development/database-schema.dbml
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

2032 lines
58 KiB
Text

table agents {
id text [pk, not null]
slug varchar(100)
title varchar(255)
description varchar(1000)
tags jsonb [default: `[]`]
editor_data jsonb
avatar text
background_color text
market_identifier text
plugins jsonb
client_id text
user_id text [not null]
agency_config jsonb
chat_config jsonb
few_shots jsonb
model text
params jsonb [default: `{}`]
provider text
system_role text
tts jsonb
virtual boolean [default: false]
pinned boolean
opening_message text
opening_questions text[] [default: `[]`]
session_group_id text
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(client_id, user_id) [name: 'client_id_user_id_unique', unique]
(slug, user_id) [name: 'agents_slug_user_id_unique', unique]
user_id [name: 'agents_user_id_idx']
title [name: 'agents_title_idx']
description [name: 'agents_description_idx']
session_group_id [name: 'agents_session_group_id_idx']
}
}
table agents_files {
file_id text [not null]
agent_id text [not null]
enabled boolean [default: true]
user_id text [not null]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(file_id, agent_id, user_id) [pk]
agent_id [name: 'agents_files_agent_id_idx']
file_id [name: 'agents_files_file_id_idx']
user_id [name: 'agents_files_user_id_idx']
}
}
table agents_knowledge_bases {
agent_id text [not null]
knowledge_base_id text [not null]
user_id text [not null]
enabled boolean [default: true]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(agent_id, knowledge_base_id) [pk]
agent_id [name: 'agents_knowledge_bases_agent_id_idx']
knowledge_base_id [name: 'agents_knowledge_bases_knowledge_base_id_idx']
user_id [name: 'agents_knowledge_bases_user_id_idx']
}
}
table agent_bot_providers {
id uuid [pk, not null, default: `gen_random_uuid()`]
agent_id text [not null]
user_id text [not null]
platform varchar(50) [not null]
application_id varchar(255) [not null]
credentials text
settings jsonb [default: `{}`]
enabled boolean [not null, default: true]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(platform, application_id) [name: 'agent_bot_providers_platform_app_id_unique', unique]
platform [name: 'agent_bot_providers_platform_idx']
agent_id [name: 'agent_bot_providers_agent_id_idx']
user_id [name: 'agent_bot_providers_user_id_idx']
}
}
table agent_cron_jobs {
id text [pk, not null]
agent_id text [not null]
group_id text
user_id text [not null]
name text
description text
enabled boolean [default: true]
cron_pattern text [not null]
timezone text [default: 'UTC']
content text [not null]
edit_data jsonb
max_executions integer
remaining_executions integer
execution_conditions jsonb
last_executed_at timestamp
total_executions integer [default: 0]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
agent_id [name: 'agent_cron_jobs_agent_id_idx']
group_id [name: 'agent_cron_jobs_group_id_idx']
user_id [name: 'agent_cron_jobs_user_id_idx']
enabled [name: 'agent_cron_jobs_enabled_idx']
remaining_executions [name: 'agent_cron_jobs_remaining_executions_idx']
last_executed_at [name: 'agent_cron_jobs_last_executed_at_idx']
}
}
table agent_documents {
id uuid [pk, not null, default: `gen_random_uuid()`]
user_id text [not null]
agent_id text [not null]
document_id varchar(255) [not null]
template_id varchar(100)
access_self integer [not null, default: 31]
access_shared integer [not null, default: 0]
access_public integer [not null, default: 0]
policy_load varchar(30) [not null, default: 'always']
policy jsonb
policy_load_position varchar(50) [not null, default: 'before-first-user']
policy_load_format varchar(20) [not null, default: 'raw']
policy_load_rule varchar(50) [not null, default: 'always']
deleted_at "timestamp with time zone"
deleted_by_user_id text
deleted_by_agent_id text
delete_reason text
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
user_id [name: 'agent_documents_user_id_idx']
agent_id [name: 'agent_documents_agent_id_idx']
access_self [name: 'agent_documents_access_self_idx']
access_shared [name: 'agent_documents_access_shared_idx']
access_public [name: 'agent_documents_access_public_idx']
policy_load [name: 'agent_documents_policy_load_idx']
template_id [name: 'agent_documents_template_id_idx']
policy_load_position [name: 'agent_documents_policy_load_position_idx']
policy_load_format [name: 'agent_documents_policy_load_format_idx']
policy_load_rule [name: 'agent_documents_policy_load_rule_idx']
(agent_id, policy_load_position) [name: 'agent_documents_agent_load_position_idx']
deleted_at [name: 'agent_documents_deleted_at_idx']
(agent_id, deleted_at, policy_load) [name: 'agent_documents_agent_autoload_deleted_idx']
document_id [name: 'agent_documents_document_id_idx']
(agent_id, document_id, user_id) [name: 'agent_documents_agent_document_user_unique', unique]
}
}
table agent_eval_benchmarks {
id text [pk, not null]
identifier text [not null]
name text [not null]
description text
rubrics jsonb [not null]
reference_url text
metadata jsonb
user_id text
is_system boolean [not null, default: true]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(identifier, user_id) [name: 'agent_eval_benchmarks_identifier_user_id_unique', unique]
is_system [name: 'agent_eval_benchmarks_is_system_idx']
user_id [name: 'agent_eval_benchmarks_user_id_idx']
}
}
table agent_eval_datasets {
id text [pk, not null]
benchmark_id text [not null]
identifier text [not null]
user_id text
name text [not null]
description text
eval_mode text
eval_config jsonb
metadata jsonb
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(identifier, user_id) [name: 'agent_eval_datasets_identifier_user_id_unique', unique]
benchmark_id [name: 'agent_eval_datasets_benchmark_id_idx']
user_id [name: 'agent_eval_datasets_user_id_idx']
}
}
table agent_eval_run_topics {
user_id text [not null]
run_id text [not null]
topic_id text [not null]
test_case_id text [not null]
status text
score real
passed boolean
eval_result jsonb
created_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(run_id, topic_id) [pk]
user_id [name: 'agent_eval_run_topics_user_id_idx']
run_id [name: 'agent_eval_run_topics_run_id_idx']
test_case_id [name: 'agent_eval_run_topics_test_case_id_idx']
}
}
table agent_eval_runs {
id text [pk, not null]
dataset_id text [not null]
target_agent_id text
user_id text [not null]
name text
status text [not null, default: 'idle']
config jsonb
metrics jsonb
started_at "timestamp with time zone"
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
dataset_id [name: 'agent_eval_runs_dataset_id_idx']
user_id [name: 'agent_eval_runs_user_id_idx']
status [name: 'agent_eval_runs_status_idx']
target_agent_id [name: 'agent_eval_runs_target_agent_id_idx']
}
}
table agent_eval_test_cases {
id text [pk, not null]
user_id text [not null]
dataset_id text [not null]
content jsonb [not null]
eval_mode text
eval_config jsonb
metadata jsonb
sort_order integer
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
user_id [name: 'agent_eval_test_cases_user_id_idx']
dataset_id [name: 'agent_eval_test_cases_dataset_id_idx']
sort_order [name: 'agent_eval_test_cases_sort_order_idx']
}
}
table agent_skills {
id text [pk, not null]
name text [not null]
description text [not null]
identifier text [not null]
source text [not null]
manifest jsonb [not null, default: `{}`]
content text
editor_data jsonb
resources jsonb [default: `{}`]
zip_file_hash varchar(64)
user_id text [not null]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(user_id, name) [name: 'agent_skills_user_name_idx', unique]
identifier [name: 'agent_skills_identifier_idx']
user_id [name: 'agent_skills_user_id_idx']
source [name: 'agent_skills_source_idx']
zip_file_hash [name: 'agent_skills_zip_hash_idx']
}
}
table ai_models {
id varchar(150) [not null]
display_name varchar(200)
description text
organization varchar(100)
enabled boolean
provider_id varchar(64) [not null]
type varchar(20) [not null, default: 'chat']
sort integer
user_id text [not null]
pricing jsonb
parameters jsonb [default: `{}`]
config jsonb
abilities jsonb [default: `{}`]
context_window_tokens integer
source varchar(20)
released_at varchar(10)
settings jsonb [default: `{}`]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(id, provider_id, user_id) [pk]
user_id [name: 'ai_models_user_id_idx']
}
}
table ai_providers {
id varchar(64) [not null]
name text
user_id text [not null]
sort integer
enabled boolean
fetch_on_client boolean
check_model text
logo text
description text
key_vaults text
source varchar(20)
settings jsonb
config jsonb
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(id, user_id) [pk]
user_id [name: 'ai_providers_user_id_idx']
}
}
table api_keys {
id text [pk, not null]
name varchar(256) [not null]
key varchar(256) [not null, unique]
key_hash varchar(128) [unique]
enabled boolean [default: true]
expires_at "timestamp with time zone"
last_used_at "timestamp with time zone"
user_id text [not null]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
user_id [name: 'api_keys_user_id_idx']
}
}
table async_tasks {
id uuid [pk, not null, default: `gen_random_uuid()`]
type text
status text
error jsonb
inference_id text
user_id text [not null]
duration integer
parent_id uuid
metadata jsonb [not null, default: '{}']
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
user_id [name: 'async_tasks_user_id_idx']
parent_id [name: 'async_tasks_parent_id_idx']
(type, status) [name: 'async_tasks_type_status_idx']
inference_id [name: 'async_tasks_inference_id_idx']
metadata [name: 'async_tasks_metadata_idx']
}
}
table accounts {
access_token text
access_token_expires_at timestamp
account_id text [not null]
created_at timestamp [not null, default: `now()`]
id text [pk, not null]
id_token text
password text
provider_id text [not null]
refresh_token text
refresh_token_expires_at timestamp
scope text
updated_at timestamp [not null]
user_id text [not null]
indexes {
user_id [name: 'account_userId_idx']
}
}
table passkey {
aaguid text
backedUp boolean
counter integer
createdAt timestamp [default: `now()`]
credentialID text [not null]
deviceType text
id text [pk, not null]
name text
publicKey text [not null]
transports text
userId text [not null]
indexes {
credentialID [name: 'passkey_credential_id_unique', unique]
userId [name: 'passkey_user_id_idx']
}
}
table auth_sessions {
created_at timestamp [not null, default: `now()`]
expires_at timestamp [not null]
id text [pk, not null]
impersonated_by text
ip_address text
token text [not null, unique]
updated_at timestamp [not null]
user_agent text
user_id text [not null]
indexes {
user_id [name: 'auth_session_userId_idx']
}
}
table two_factor {
backup_codes text [not null]
id text [pk, not null]
secret text [not null]
user_id text [not null]
indexes {
secret [name: 'two_factor_secret_idx']
user_id [name: 'two_factor_user_id_idx']
}
}
table verifications {
created_at timestamp [not null, default: `now()`]
expires_at timestamp [not null]
id text [pk, not null]
identifier text [not null]
updated_at timestamp [not null, default: `now()`]
value text [not null]
indexes {
identifier [name: 'verification_identifier_idx']
}
}
table chat_groups {
id text [pk, not null]
title text
description text
avatar text
background_color text
market_identifier text
content text
editor_data jsonb
config jsonb
client_id text
user_id text [not null]
group_id text
pinned boolean [default: false]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(client_id, user_id) [name: 'chat_groups_client_id_user_id_unique', unique]
user_id [name: 'chat_groups_user_id_idx']
group_id [name: 'chat_groups_group_id_idx']
}
}
table chat_groups_agents {
chat_group_id text [not null]
agent_id text [not null]
user_id text [not null]
enabled boolean [default: true]
order integer [default: 0]
role text [default: 'participant']
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(chat_group_id, agent_id) [pk]
user_id [name: 'chat_groups_agents_user_id_idx']
}
}
table documents {
id varchar(255) [pk, not null]
title text
description text
content text
file_type varchar(255) [not null]
filename text
total_char_count integer [not null]
total_line_count integer [not null]
metadata jsonb
pages jsonb
source_type text [not null]
source text [not null]
file_id text
knowledge_base_id text
parent_id varchar(255)
user_id text [not null]
client_id text
editor_data jsonb
slug varchar(255)
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
source [name: 'documents_source_idx']
file_type [name: 'documents_file_type_idx']
source_type [name: 'documents_source_type_idx']
user_id [name: 'documents_user_id_idx']
file_id [name: 'documents_file_id_idx']
parent_id [name: 'documents_parent_id_idx']
knowledge_base_id [name: 'documents_knowledge_base_id_idx']
(client_id, user_id) [name: 'documents_client_id_user_id_unique', unique]
(slug, user_id) [name: 'documents_slug_user_id_unique', unique]
}
}
table files {
id text [pk, not null]
user_id text [not null]
file_type varchar(255) [not null]
file_hash varchar(64)
name text [not null]
size integer [not null]
url text [not null]
source text
parent_id varchar(255)
client_id text
metadata jsonb
chunk_task_id uuid
embedding_task_id uuid
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
file_hash [name: 'file_hash_idx']
user_id [name: 'files_user_id_idx']
parent_id [name: 'files_parent_id_idx']
chunk_task_id [name: 'files_chunk_task_id_idx']
embedding_task_id [name: 'files_embedding_task_id_idx']
(client_id, user_id) [name: 'files_client_id_user_id_unique', unique]
}
}
table global_files {
hash_id varchar(64) [pk, not null]
file_type varchar(255) [not null]
size integer [not null]
url text [not null]
metadata jsonb
creator text [not null]
created_at "timestamp with time zone" [not null, default: `now()`]
accessed_at "timestamp with time zone" [not null, default: `now()`]
indexes {
creator [name: 'global_files_creator_idx']
}
}
table knowledge_base_files {
knowledge_base_id text [not null]
file_id text [not null]
user_id text [not null]
created_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(knowledge_base_id, file_id) [pk]
knowledge_base_id [name: 'knowledge_base_files_kb_id_idx']
user_id [name: 'knowledge_base_files_user_id_idx']
file_id [name: 'knowledge_base_files_file_id_idx']
}
}
table knowledge_bases {
id text [pk, not null]
name text [not null]
description text
avatar text
type text
user_id text [not null]
client_id text
is_public boolean [default: false]
settings jsonb
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(client_id, user_id) [name: 'knowledge_bases_client_id_user_id_unique', unique]
user_id [name: 'knowledge_bases_user_id_idx']
}
}
table generation_batches {
id text [pk, not null]
user_id text [not null]
generation_topic_id text [not null]
provider text [not null]
model text [not null]
prompt text [not null]
width integer
height integer
ratio varchar(64)
config jsonb
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
user_id [name: 'generation_batches_user_id_idx']
generation_topic_id [name: 'generation_batches_topic_id_idx']
}
}
table generation_topics {
id text [pk, not null]
user_id text [not null]
title text
cover_url text
type varchar(32) [not null, default: 'image']
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
user_id [name: 'generation_topics_user_id_idx']
}
}
table generations {
id text [pk, not null]
user_id text [not null]
generation_batch_id varchar(64) [not null]
async_task_id uuid
file_id text
seed integer
asset jsonb
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
user_id [name: 'generations_user_id_idx']
generation_batch_id [name: 'generations_batch_id_idx']
file_id [name: 'generations_file_id_idx']
}
}
table message_chunks {
message_id text
chunk_id uuid
user_id text [not null]
indexes {
(chunk_id, message_id) [pk]
user_id [name: 'message_chunks_user_id_idx']
message_id [name: 'message_chunks_message_id_idx']
}
}
table message_groups {
id varchar(255) [pk, not null]
topic_id text
user_id text [not null]
parent_group_id varchar(255)
parent_message_id text
title varchar(255)
description text
type text
content text
editor_data jsonb
metadata jsonb
client_id varchar(255)
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(client_id, user_id) [name: 'message_groups_client_id_user_id_unique', unique]
user_id [name: 'message_groups_user_id_idx']
topic_id [name: 'message_groups_topic_id_idx']
type [name: 'message_groups_type_idx']
parent_group_id [name: 'message_groups_parent_group_id_idx']
parent_message_id [name: 'message_groups_parent_message_id_idx']
}
}
table message_plugins {
id text [pk, not null]
tool_call_id text
type text [default: 'default']
intervention jsonb
api_name text
arguments text
identifier text
state jsonb
error jsonb
client_id text
user_id text [not null]
indexes {
(client_id, user_id) [name: 'message_plugins_client_id_user_id_unique', unique]
user_id [name: 'message_plugins_user_id_idx']
tool_call_id [name: 'message_plugins_tool_call_id_idx']
}
}
table message_queries {
id uuid [pk, not null, default: `gen_random_uuid()`]
message_id text [not null]
rewrite_query text
user_query text
client_id text
user_id text [not null]
embeddings_id uuid
indexes {
(client_id, user_id) [name: 'message_queries_client_id_user_id_unique', unique]
user_id [name: 'message_queries_user_id_idx']
message_id [name: 'message_queries_message_id_idx']
embeddings_id [name: 'message_queries_embeddings_id_idx']
}
}
table message_query_chunks {
id text
query_id uuid
chunk_id uuid
similarity "numeric(6, 5)"
user_id text [not null]
indexes {
(chunk_id, id, query_id) [pk]
user_id [name: 'message_query_chunks_user_id_idx']
id [name: 'message_query_chunks_message_id_idx']
query_id [name: 'message_query_chunks_query_id_idx']
}
}
table message_tts {
id text [pk, not null]
content_md5 text
file_id text
voice text
client_id text
user_id text [not null]
indexes {
(client_id, user_id) [name: 'message_tts_client_id_user_id_unique', unique]
user_id [name: 'message_tts_user_id_idx']
}
}
table message_translates {
id text [pk, not null]
content text
from text
to text
client_id text
user_id text [not null]
indexes {
(client_id, user_id) [name: 'message_translates_client_id_user_id_unique', unique]
user_id [name: 'message_translates_user_id_idx']
}
}
table messages {
id text [pk, not null]
role varchar(255) [not null]
content text
editor_data jsonb
summary text
reasoning jsonb
search jsonb
metadata jsonb
model text
provider text
favorite boolean [default: false]
error jsonb
tools jsonb
trace_id text
observation_id text
client_id text
user_id text [not null]
session_id text
topic_id text
thread_id text
parent_id text
quota_id text
agent_id text
group_id text
target_id text
message_group_id varchar(255)
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
created_at [name: 'messages_created_at_idx']
(client_id, user_id) [name: 'message_client_id_user_unique', unique]
topic_id [name: 'messages_topic_id_idx']
parent_id [name: 'messages_parent_id_idx']
quota_id [name: 'messages_quota_id_idx']
user_id [name: 'messages_user_id_idx']
session_id [name: 'messages_session_id_idx']
thread_id [name: 'messages_thread_id_idx']
agent_id [name: 'messages_agent_id_idx']
group_id [name: 'messages_group_id_idx']
message_group_id [name: 'messages_message_group_id_idx']
}
}
table messages_files {
file_id text [not null]
message_id text [not null]
user_id text [not null]
indexes {
(file_id, message_id) [pk]
user_id [name: 'messages_files_user_id_idx']
message_id [name: 'messages_files_message_id_idx']
}
}
table nextauth_accounts {
access_token text
expires_at integer
id_token text
provider text [not null]
providerAccountId text [not null]
refresh_token text
scope text
session_state text
token_type text
type text [not null]
user_id text [not null]
indexes {
(provider, providerAccountId) [pk]
user_id [name: 'nextauth_accounts_user_id_idx']
}
}
table nextauth_authenticators {
counter integer [not null]
credentialBackedUp boolean [not null]
credentialDeviceType text [not null]
credentialID text [not null, unique]
credentialPublicKey text [not null]
providerAccountId text [not null]
transports text
user_id text [not null]
indexes {
(user_id, credentialID) [pk]
}
}
table nextauth_sessions {
expires timestamp [not null]
sessionToken text [pk, not null]
user_id text [not null]
indexes {
user_id [name: 'nextauth_sessions_user_id_idx']
}
}
table nextauth_verificationtokens {
expires timestamp [not null]
identifier text [not null]
token text [not null]
indexes {
(identifier, token) [pk]
}
}
table notification_deliveries {
id uuid [pk, not null, default: `gen_random_uuid()`]
notification_id uuid [not null]
channel text [not null]
status text [not null]
provider_message_id text
failed_reason text
sent_at "timestamp with time zone"
created_at "timestamp with time zone" [not null, default: `now()`]
indexes {
notification_id [name: 'idx_deliveries_notification']
channel [name: 'idx_deliveries_channel']
status [name: 'idx_deliveries_status']
}
}
table notifications {
id uuid [pk, not null, default: `gen_random_uuid()`]
user_id text [not null]
category text [not null]
type text [not null]
title text [not null]
content text [not null]
dedupe_key text
action_url text
is_read boolean [not null, default: false]
is_archived boolean [not null, default: false]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
user_id [name: 'idx_notifications_user']
(user_id, created_at) [name: 'idx_notifications_user_active']
user_id [name: 'idx_notifications_user_unread']
(user_id, dedupe_key) [name: 'idx_notifications_dedupe', unique]
(updated_at, created_at, id) [name: 'idx_notifications_archived_cleanup']
}
}
table oauth_handoffs {
id text [pk, not null]
client varchar(50) [not null]
payload jsonb [not null]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
}
table oidc_access_tokens {
id varchar(255) [pk, not null]
data jsonb [not null]
expires_at "timestamp with time zone" [not null]
consumed_at "timestamp with time zone"
user_id text [not null]
client_id varchar(255) [not null]
grant_id varchar(255)
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
user_id [name: 'oidc_access_tokens_user_id_idx']
}
}
table oidc_authorization_codes {
id varchar(255) [pk, not null]
data jsonb [not null]
expires_at "timestamp with time zone" [not null]
consumed_at "timestamp with time zone"
user_id text [not null]
client_id varchar(255) [not null]
grant_id varchar(255)
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
user_id [name: 'oidc_authorization_codes_user_id_idx']
}
}
table oidc_clients {
id varchar(255) [pk, not null]
name text [not null]
description text
client_secret varchar(255)
redirect_uris text[] [not null]
grants text[] [not null]
response_types text[] [not null]
scopes text[] [not null]
token_endpoint_auth_method varchar(20)
application_type varchar(20)
client_uri text
logo_uri text
policy_uri text
tos_uri text
is_first_party boolean [default: false]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
}
table oidc_consents {
user_id text [not null]
client_id varchar(255) [not null]
scopes text[] [not null]
expires_at "timestamp with time zone"
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(user_id, client_id) [pk]
}
}
table oidc_device_codes {
id varchar(255) [pk, not null]
data jsonb [not null]
expires_at "timestamp with time zone" [not null]
consumed_at "timestamp with time zone"
user_id text
client_id varchar(255) [not null]
grant_id varchar(255)
user_code varchar(255)
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
user_id [name: 'oidc_device_codes_user_id_idx']
}
}
table oidc_grants {
id varchar(255) [pk, not null]
data jsonb [not null]
expires_at "timestamp with time zone" [not null]
consumed_at "timestamp with time zone"
user_id text [not null]
client_id varchar(255) [not null]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
user_id [name: 'oidc_grants_user_id_idx']
}
}
table oidc_interactions {
id varchar(255) [pk, not null]
data jsonb [not null]
expires_at "timestamp with time zone" [not null]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
}
table oidc_refresh_tokens {
id varchar(255) [pk, not null]
data jsonb [not null]
expires_at "timestamp with time zone" [not null]
consumed_at "timestamp with time zone"
user_id text [not null]
client_id varchar(255) [not null]
grant_id varchar(255)
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
user_id [name: 'oidc_refresh_tokens_user_id_idx']
}
}
table oidc_sessions {
id varchar(255) [pk, not null]
data jsonb [not null]
expires_at "timestamp with time zone" [not null]
user_id text [not null]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
user_id [name: 'oidc_sessions_user_id_idx']
}
}
table chunks {
id uuid [pk, not null, default: `gen_random_uuid()`]
text text
abstract text
metadata jsonb
index integer
type varchar
client_id text
user_id text
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(client_id, user_id) [name: 'chunks_client_id_user_id_unique', unique]
user_id [name: 'chunks_user_id_idx']
}
}
table document_chunks {
document_id varchar(30) [not null]
chunk_id uuid [not null]
page_index integer
user_id text [not null]
created_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(document_id, chunk_id) [pk]
document_id [name: 'document_chunks_document_id_idx']
chunk_id [name: 'document_chunks_chunk_id_idx']
user_id [name: 'document_chunks_user_id_idx']
}
}
table embeddings {
id uuid [pk, not null, default: `gen_random_uuid()`]
chunk_id uuid [unique]
embeddings vector(1024)
model text
client_id text
user_id text
indexes {
(client_id, user_id) [name: 'embeddings_client_id_user_id_unique', unique]
chunk_id [name: 'embeddings_chunk_id_idx']
user_id [name: 'embeddings_user_id_idx']
}
}
table unstructured_chunks {
id uuid [pk, not null, default: `gen_random_uuid()`]
text text
metadata jsonb
index integer
type varchar
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
parent_id varchar
composite_id uuid
client_id text
user_id text
file_id varchar
indexes {
(client_id, user_id) [name: 'unstructured_chunks_client_id_user_id_unique', unique]
user_id [name: 'unstructured_chunks_user_id_idx']
composite_id [name: 'unstructured_chunks_composite_id_idx']
file_id [name: 'unstructured_chunks_file_id_idx']
}
}
table rag_eval_dataset_records {
id text [pk, not null]
dataset_id text [not null]
ideal text
question text
reference_files text[]
metadata jsonb
user_id text
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
user_id [name: 'rag_eval_dataset_records_user_id_idx']
}
}
table rag_eval_datasets {
id text [pk, not null]
description text
name text [not null]
knowledge_base_id text
user_id text
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
user_id [name: 'rag_eval_datasets_user_id_idx']
}
}
table rag_eval_evaluations {
id text [pk, not null]
name text [not null]
description text
eval_records_url text
status text
error jsonb
dataset_id text [not null]
knowledge_base_id text
language_model text
embedding_model text
user_id text
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
user_id [name: 'rag_eval_evaluations_user_id_idx']
}
}
table rag_eval_evaluation_records {
id text [pk, not null]
question text [not null]
answer text
context text[]
ideal text
status text
error jsonb
language_model text
embedding_model text
question_embedding_id uuid
duration integer
dataset_record_id text [not null]
evaluation_id text [not null]
user_id text
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
user_id [name: 'rag_eval_evaluation_records_user_id_idx']
}
}
table rbac_permissions {
id text [pk, not null]
code text [not null, unique]
name text [not null]
description text
category text [not null]
is_active boolean [not null, default: true]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
}
table rbac_role_permissions {
role_id text [not null]
permission_id text [not null]
created_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(role_id, permission_id) [pk]
role_id [name: 'rbac_role_permissions_role_id_idx']
permission_id [name: 'rbac_role_permissions_permission_id_idx']
}
}
table rbac_roles {
id text [pk, not null]
name text [not null, unique]
display_name text [not null]
description text
is_system boolean [not null, default: false]
is_active boolean [not null, default: true]
metadata jsonb [default: `{}`]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
}
table rbac_user_roles {
user_id text [not null]
role_id text [not null]
created_at "timestamp with time zone" [not null, default: `now()`]
expires_at "timestamp with time zone"
indexes {
(user_id, role_id) [pk]
user_id [name: 'rbac_user_roles_user_id_idx']
role_id [name: 'rbac_user_roles_role_id_idx']
}
}
table agents_to_sessions {
agent_id text [not null]
session_id text [not null]
user_id text [not null]
indexes {
(agent_id, session_id) [pk]
session_id [name: 'agents_to_sessions_session_id_idx']
agent_id [name: 'agents_to_sessions_agent_id_idx']
user_id [name: 'agents_to_sessions_user_id_idx']
}
}
table file_chunks {
file_id varchar
chunk_id uuid
created_at "timestamp with time zone" [not null, default: `now()`]
user_id text [not null]
indexes {
(file_id, chunk_id) [pk]
user_id [name: 'file_chunks_user_id_idx']
file_id [name: 'file_chunks_file_id_idx']
chunk_id [name: 'file_chunks_chunk_id_idx']
}
}
table files_to_sessions {
file_id text [not null]
session_id text [not null]
user_id text [not null]
indexes {
(file_id, session_id) [pk]
user_id [name: 'files_to_sessions_user_id_idx']
file_id [name: 'files_to_sessions_file_id_idx']
session_id [name: 'files_to_sessions_session_id_idx']
}
}
table session_groups {
id text [pk, not null]
name text [not null]
sort integer
user_id text [not null]
client_id text
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(client_id, user_id) [name: 'session_groups_client_id_user_id_unique', unique]
user_id [name: 'session_groups_user_id_idx']
}
}
table sessions {
id text [pk, not null]
slug varchar(100) [not null]
title text
description text
avatar text
background_color text
type text [default: 'agent']
user_id text [not null]
group_id text
client_id text
pinned boolean [default: false]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(slug, user_id) [name: 'slug_user_id_unique', unique]
(client_id, user_id) [name: 'sessions_client_id_user_id_unique', unique]
user_id [name: 'sessions_user_id_idx']
(id, user_id) [name: 'sessions_id_user_id_idx']
(user_id, updated_at) [name: 'sessions_user_id_updated_at_idx']
group_id [name: 'sessions_group_id_idx']
}
}
table briefs {
id text [pk, not null]
user_id text [not null]
task_id text
cron_job_id text
topic_id text
agent_id text
type text [not null]
priority text [default: 'info']
title text [not null]
summary text [not null]
artifacts jsonb
actions jsonb
resolved_action text
resolved_comment text
read_at "timestamp with time zone"
resolved_at "timestamp with time zone"
created_at "timestamp with time zone" [not null, default: `now()`]
indexes {
user_id [name: 'briefs_user_id_idx']
task_id [name: 'briefs_task_id_idx']
cron_job_id [name: 'briefs_cron_job_id_idx']
agent_id [name: 'briefs_agent_id_idx']
type [name: 'briefs_type_idx']
priority [name: 'briefs_priority_idx']
(user_id, resolved_at) [name: 'briefs_unresolved_idx']
}
}
table task_comments {
id text [pk, not null]
task_id text [not null]
user_id text [not null]
author_user_id text
author_agent_id text
content text [not null]
editor_data jsonb
brief_id text
topic_id text
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
task_id [name: 'task_comments_task_id_idx']
user_id [name: 'task_comments_user_id_idx']
author_user_id [name: 'task_comments_author_user_id_idx']
author_agent_id [name: 'task_comments_agent_id_idx']
brief_id [name: 'task_comments_brief_id_idx']
topic_id [name: 'task_comments_topic_id_idx']
}
}
table task_dependencies {
id uuid [pk, not null, default: `gen_random_uuid()`]
task_id text [not null]
depends_on_id text [not null]
user_id text [not null]
type text [not null, default: 'blocks']
condition jsonb
created_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(task_id, depends_on_id) [name: 'task_deps_unique_idx', unique]
task_id [name: 'task_deps_task_id_idx']
depends_on_id [name: 'task_deps_depends_on_id_idx']
user_id [name: 'task_deps_user_id_idx']
}
}
table task_documents {
id uuid [pk, not null, default: `gen_random_uuid()`]
task_id text [not null]
document_id text [not null]
user_id text [not null]
pinned_by text [not null, default: 'agent']
created_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(task_id, document_id) [name: 'task_docs_unique_idx', unique]
task_id [name: 'task_docs_task_id_idx']
document_id [name: 'task_docs_document_id_idx']
user_id [name: 'task_docs_user_id_idx']
}
}
table task_topics {
id uuid [pk, not null, default: `gen_random_uuid()`]
task_id text [not null]
topic_id text
user_id text [not null]
seq integer [not null]
operation_id text
status text [not null, default: 'running']
handoff jsonb
review_passed integer
review_score integer
review_scores jsonb
review_iteration integer
reviewed_at "timestamp with time zone"
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(task_id, topic_id) [name: 'task_topics_unique_idx', unique]
task_id [name: 'task_topics_task_id_idx']
topic_id [name: 'task_topics_topic_id_idx']
user_id [name: 'task_topics_user_id_idx']
(task_id, status) [name: 'task_topics_status_idx']
}
}
table tasks {
id text [pk, not null]
identifier text [not null]
seq integer [not null]
created_by_user_id text [not null]
created_by_agent_id text
assignee_user_id text
assignee_agent_id text
parent_task_id text
name text
description varchar(255)
instruction text [not null]
status text [not null, default: 'backlog']
priority integer [default: 0]
sort_order integer [default: 0]
heartbeat_interval integer [default: 300]
heartbeat_timeout integer
last_heartbeat_at "timestamp with time zone"
schedule_pattern text
schedule_timezone text [default: 'UTC']
total_topics integer [default: 0]
max_topics integer
current_topic_id text
context jsonb [default: `{}`]
config jsonb [default: `{}`]
error text
started_at "timestamp with time zone"
completed_at "timestamp with time zone"
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(identifier, created_by_user_id) [name: 'tasks_identifier_idx', unique]
created_by_user_id [name: 'tasks_created_by_user_id_idx']
created_by_agent_id [name: 'tasks_created_by_agent_id_idx']
assignee_user_id [name: 'tasks_assignee_user_id_idx']
assignee_agent_id [name: 'tasks_assignee_agent_id_idx']
parent_task_id [name: 'tasks_parent_task_id_idx']
status [name: 'tasks_status_idx']
priority [name: 'tasks_priority_idx']
(status, last_heartbeat_at) [name: 'tasks_heartbeat_idx']
}
}
table threads {
id text [pk, not null]
title text
content text
editor_data jsonb
type text [not null]
status text
topic_id text [not null]
source_message_id text
parent_thread_id text
client_id text
agent_id text
group_id text
metadata jsonb
user_id text [not null]
last_active_at "timestamp with time zone" [default: `now()`]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(client_id, user_id) [name: 'threads_client_id_user_id_unique', unique]
user_id [name: 'threads_user_id_idx']
topic_id [name: 'threads_topic_id_idx']
type [name: 'threads_type_idx']
agent_id [name: 'threads_agent_id_idx']
group_id [name: 'threads_group_id_idx']
parent_thread_id [name: 'threads_parent_thread_id_idx']
}
}
table topic_documents {
document_id text [not null]
topic_id text [not null]
user_id text [not null]
created_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(document_id, topic_id) [pk]
user_id [name: 'topic_documents_user_id_idx']
topic_id [name: 'topic_documents_topic_id_idx']
document_id [name: 'topic_documents_document_id_idx']
}
}
table topic_shares {
id text [pk, not null]
topic_id text [not null]
user_id text [not null]
visibility text [not null, default: 'private']
page_view_count integer [not null, default: 0]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
topic_id [name: 'topic_shares_topic_id_unique', unique]
user_id [name: 'topic_shares_user_id_idx']
}
}
table topics {
id text [pk, not null]
title text
favorite boolean [default: false]
session_id text
content text
editor_data jsonb
agent_id text
group_id text
user_id text [not null]
client_id text
description text
history_summary text
metadata jsonb
trigger text
mode text
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(client_id, user_id) [name: 'topics_client_id_user_id_unique', unique]
user_id [name: 'topics_user_id_idx']
(id, user_id) [name: 'topics_id_user_id_idx']
session_id [name: 'topics_session_id_idx']
group_id [name: 'topics_group_id_idx']
agent_id [name: 'topics_agent_id_idx']
trigger [name: 'topics_trigger_idx']
() [name: 'topics_extract_status_gin_idx']
}
}
table user_installed_plugins {
user_id text [not null]
identifier text [not null]
type text [not null]
manifest jsonb
settings jsonb
custom_params jsonb
source varchar(255)
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(user_id, identifier) [pk]
}
}
table user_settings {
id text [pk, not null]
tts jsonb
hotkey jsonb
key_vaults text
general jsonb
language_model jsonb
system_agent jsonb
default_agent jsonb
market jsonb
memory jsonb
tool jsonb
image jsonb
notification jsonb
}
table users {
id text [pk, not null]
username text [unique]
email text [unique]
normalized_email text [unique]
avatar text
phone text [unique]
first_name text
last_name text
full_name text
interests "varchar(64)[]"
is_onboarded boolean [default: false]
onboarding jsonb
clerk_created_at "timestamp with time zone"
email_verified boolean [not null, default: false]
email_verified_at "timestamp with time zone"
preference jsonb
role text
banned boolean [default: false]
ban_reason text
ban_expires "timestamp with time zone"
two_factor_enabled boolean [default: false]
phone_number_verified boolean
last_active_at "timestamp with time zone" [not null, default: `now()`]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
email [name: 'users_email_idx']
username [name: 'users_username_idx']
created_at [name: 'users_created_at_idx']
created_at [name: 'users_banned_true_created_at_idx']
}
}
table user_memories {
id varchar(255) [pk, not null]
user_id text
memory_category varchar(255)
memory_layer varchar(255)
memory_type varchar(255)
metadata jsonb
tags text[]
title varchar(255)
summary text
summary_vector_1024 vector(1024)
details text
details_vector_1024 vector(1024)
status varchar(255)
accessed_count bigint [default: 0]
last_accessed_at "timestamp with time zone" [not null]
captured_at "timestamp with time zone" [not null, default: `now()`]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
summary_vector_1024 [name: 'user_memories_summary_vector_1024_index']
details_vector_1024 [name: 'user_memories_details_vector_1024_index']
user_id [name: 'user_memories_user_id_index']
}
}
table user_memories_activities {
id varchar(255) [pk, not null]
user_id text
user_memory_id varchar(255)
metadata jsonb
tags text[]
type varchar(255) [not null]
status varchar(255) [not null, default: 'pending']
timezone varchar(255)
starts_at "timestamp with time zone"
ends_at "timestamp with time zone"
associated_objects jsonb
associated_subjects jsonb
associated_locations jsonb
notes text
narrative text
narrative_vector vector(1024)
feedback text
feedback_vector vector(1024)
captured_at "timestamp with time zone" [not null, default: `now()`]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
narrative_vector [name: 'user_memories_activities_narrative_vector_index']
feedback_vector [name: 'user_memories_activities_feedback_vector_index']
type [name: 'user_memories_activities_type_index']
user_id [name: 'user_memories_activities_user_id_index']
user_memory_id [name: 'user_memories_activities_user_memory_id_index']
status [name: 'user_memories_activities_status_index']
}
}
table user_memories_contexts {
id varchar(255) [pk, not null]
user_id text
user_memory_ids jsonb
metadata jsonb
tags text[]
associated_objects jsonb
associated_subjects jsonb
title text
description text
description_vector vector(1024)
type varchar(255)
current_status text
score_impact numeric [default: 0]
score_urgency numeric [default: 0]
captured_at "timestamp with time zone" [not null, default: `now()`]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
description_vector [name: 'user_memories_contexts_description_vector_index']
type [name: 'user_memories_contexts_type_index']
user_id [name: 'user_memories_contexts_user_id_index']
}
}
table user_memories_experiences {
id varchar(255) [pk, not null]
user_id text
user_memory_id varchar(255)
metadata jsonb
tags text[]
type varchar(255)
situation text
situation_vector vector(1024)
reasoning text
possible_outcome text
action text
action_vector vector(1024)
key_learning text
key_learning_vector vector(1024)
score_confidence real [default: 0]
captured_at "timestamp with time zone" [not null, default: `now()`]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
situation_vector [name: 'user_memories_experiences_situation_vector_index']
action_vector [name: 'user_memories_experiences_action_vector_index']
key_learning_vector [name: 'user_memories_experiences_key_learning_vector_index']
type [name: 'user_memories_experiences_type_index']
user_id [name: 'user_memories_experiences_user_id_index']
user_memory_id [name: 'user_memories_experiences_user_memory_id_index']
}
}
table user_memories_identities {
id varchar(255) [pk, not null]
user_id text
user_memory_id varchar(255)
metadata jsonb
tags text[]
type varchar(255)
description text
description_vector vector(1024)
episodic_date "timestamp with time zone"
relationship varchar(255)
role text
captured_at "timestamp with time zone" [not null, default: `now()`]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
description_vector [name: 'user_memories_identities_description_vector_index']
type [name: 'user_memories_identities_type_index']
user_id [name: 'user_memories_identities_user_id_index']
user_memory_id [name: 'user_memories_identities_user_memory_id_index']
}
}
table user_memories_preferences {
id varchar(255) [pk, not null]
user_id text
user_memory_id varchar(255)
metadata jsonb
tags text[]
conclusion_directives text
conclusion_directives_vector vector(1024)
type varchar(255)
suggestions text
score_priority numeric [default: 0]
captured_at "timestamp with time zone" [not null, default: `now()`]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
conclusion_directives_vector [name: 'user_memories_preferences_conclusion_directives_vector_index']
user_id [name: 'user_memories_preferences_user_id_index']
user_memory_id [name: 'user_memories_preferences_user_memory_id_index']
}
}
table user_memory_persona_document_histories {
id varchar(255) [pk, not null]
user_id text
persona_id varchar(255)
profile varchar(255) [not null, default: 'default']
snapshot_persona text
snapshot_tagline text
reasoning text
diff_persona text
diff_tagline text
snapshot text
summary text
edited_by varchar(255) [default: 'agent']
memory_ids jsonb
source_ids jsonb
metadata jsonb
previous_version integer
next_version integer
captured_at "timestamp with time zone" [not null, default: `now()`]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
persona_id [name: 'user_persona_document_histories_persona_id_index']
user_id [name: 'user_persona_document_histories_user_id_index']
profile [name: 'user_persona_document_histories_profile_index']
}
}
table user_memory_persona_documents {
id varchar(255) [pk, not null]
user_id text
profile varchar(255) [not null, default: 'default']
tagline text
persona text
memory_ids jsonb
source_ids jsonb
metadata jsonb
version integer [not null, default: 1]
captured_at "timestamp with time zone" [not null, default: `now()`]
accessed_at "timestamp with time zone" [not null, default: `now()`]
created_at "timestamp with time zone" [not null, default: `now()`]
updated_at "timestamp with time zone" [not null, default: `now()`]
indexes {
(user_id, profile) [name: 'user_persona_documents_user_id_profile_unique', unique]
user_id [name: 'user_persona_documents_user_id_index']
}
}
ref: agent_skills.user_id - users.id
ref: agent_skills.zip_file_hash - global_files.hash_id
ref: accounts.user_id > users.id
ref: passkey.userId > users.id
ref: auth_sessions.user_id > users.id
ref: two_factor.user_id > users.id
ref: agent_eval_datasets.benchmark_id > agent_eval_benchmarks.id
ref: agent_eval_datasets.user_id - users.id
ref: agent_eval_run_topics.run_id > agent_eval_runs.id
ref: agent_eval_run_topics.topic_id - topics.id
ref: agent_eval_run_topics.test_case_id > agent_eval_test_cases.id
ref: agent_eval_runs.dataset_id > agent_eval_datasets.id
ref: agent_eval_runs.target_agent_id - agents.id
ref: agent_eval_runs.user_id - users.id
ref: agent_eval_test_cases.dataset_id > agent_eval_datasets.id
ref: agents_files.file_id > files.id
ref: agents_files.agent_id > agents.id
ref: agents_knowledge_bases.knowledge_base_id - knowledge_bases.id
ref: agents_knowledge_bases.agent_id > agents.id
ref: agents_to_sessions.session_id > sessions.id
ref: agents_to_sessions.agent_id > agents.id
ref: chat_groups_agents.chat_group_id > chat_groups.id
ref: chat_groups_agents.agent_id > agents.id
ref: chat_groups_agents.user_id - users.id
ref: chat_groups.user_id - users.id
ref: unstructured_chunks.file_id - files.id
ref: document_chunks.document_id > documents.id
ref: documents.file_id > files.id
ref: file_chunks.file_id - files.id
ref: file_chunks.chunk_id - chunks.id
ref: generations.file_id - files.id
ref: files.embedding_task_id - async_tasks.id
ref: files_to_sessions.file_id > files.id
ref: files_to_sessions.session_id > sessions.id
ref: generation_batches.user_id - users.id
ref: generation_batches.generation_topic_id > generation_topics.id
ref: generation_topics.user_id - users.id
ref: generations.user_id - users.id
ref: generations.generation_batch_id > generation_batches.id
ref: generations.async_task_id - async_tasks.id
ref: message_groups.user_id - users.id
ref: message_groups.topic_id - topics.id
ref: message_groups.parent_group_id > message_groups.id
ref: messages_files.file_id > files.id
ref: messages_files.message_id > messages.id
ref: messages.id - message_translates.id
ref: messages.session_id - sessions.id
ref: messages.parent_id - messages.id
ref: messages.topic_id - topics.id
ref: threads.source_message_id - messages.id
ref: messages.message_group_id > message_groups.id
ref: sessions.group_id - session_groups.id
ref: topic_documents.document_id > documents.id
ref: topic_documents.topic_id > topics.id
ref: topics.session_id - sessions.id