diff --git a/apps/desktop/drizzle/0101_furry_garia.sql b/apps/desktop/drizzle/0101_furry_garia.sql new file mode 100644 index 00000000000..e0ac49d1ecf --- /dev/null +++ b/apps/desktop/drizzle/0101_furry_garia.sql @@ -0,0 +1 @@ +SELECT 1; diff --git a/apps/desktop/drizzle/meta/0101_snapshot.json b/apps/desktop/drizzle/meta/0101_snapshot.json new file mode 100644 index 00000000000..fa360bb8b5a --- /dev/null +++ b/apps/desktop/drizzle/meta/0101_snapshot.json @@ -0,0 +1,4572 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "9921dfad-42a2-485b-ba4b-79436d2f9184", + "prevId": "1c0c9a94-48aa-47c5-96f7-fba5d408570e", + "tables": { + "account_usage_snapshots": { + "name": "account_usage_snapshots", + "columns": { + "agent_kind": { + "name": "agent_kind", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "snapshot": { + "name": "snapshot", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "agent_input_queue_snapshots": { + "name": "agent_input_queue_snapshots", + "columns": { + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "payload": { + "name": "payload", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "agent_input_queue_snapshots_session_id_sessions_id_fk": { + "name": "agent_input_queue_snapshots_session_id_sessions_id_fk", + "tableFrom": "agent_input_queue_snapshots", + "tableTo": "sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "custom_mcp_servers": { + "name": "custom_mcp_servers", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "transport": { + "name": "transport", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "headers": { + "name": "headers", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'{}'" + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "idx_custom_mcp_servers_sort_order": { + "name": "idx_custom_mcp_servers_sort_order", + "columns": [ + "sort_order" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "custom_providers": { + "name": "custom_providers", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "runtimes": { + "name": "runtimes", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'{}'" + }, + "auth": { + "name": "auth", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "idx_custom_providers_sort_order": { + "name": "idx_custom_providers_sort_order", + "columns": [ + "sort_order" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "daily_model_usage": { + "name": "daily_model_usage", + "columns": { + "day": { + "name": "day", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_kind": { + "name": "agent_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "cost_usd": { + "name": "cost_usd", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "cost_amount": { + "name": "cost_amount", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "cost_currency": { + "name": "cost_currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'USD'" + }, + "cost_is_approximate": { + "name": "cost_is_approximate", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "input_tokens": { + "name": "input_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "output_tokens": { + "name": "output_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "cache_read_tokens": { + "name": "cache_read_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "cache_create_tokens": { + "name": "cache_create_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "daily_model_usage_day_agent_kind_model_cost_currency_pk": { + "columns": [ + "day", + "agent_kind", + "model", + "cost_currency" + ], + "name": "daily_model_usage_day_agent_kind_model_cost_currency_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "daily_spend": { + "name": "daily_spend", + "columns": { + "day": { + "name": "day", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "cost_usd": { + "name": "cost_usd", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "cost_amount": { + "name": "cost_amount", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "cost_currency": { + "name": "cost_currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'USD'" + }, + "cost_is_approximate": { + "name": "cost_is_approximate", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "daily_spend_day_cost_currency_pk": { + "columns": [ + "day", + "cost_currency" + ], + "name": "daily_spend_day_cost_currency_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "device_link_ownership": { + "name": "device_link_ownership", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "owner_pid": { + "name": "owner_pid", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "owner_label": { + "name": "owner_label", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "heartbeat_at": { + "name": "heartbeat_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "embedding_jobs": { + "name": "embedding_jobs", + "columns": { + "rowid": { + "name": "rowid", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source_id": { + "name": "source_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "chunk_index": { + "name": "chunk_index", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "model_id": { + "name": "model_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "vec_table": { + "name": "vec_table", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scheduled_at": { + "name": "scheduled_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "locked_at": { + "name": "locked_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "uniq_embedding_jobs_natural": { + "name": "uniq_embedding_jobs_natural", + "columns": [ + "source", + "source_id", + "chunk_index", + "model_id" + ], + "isUnique": true + }, + "idx_embedding_jobs_status_scheduled": { + "name": "idx_embedding_jobs_status_scheduled", + "columns": [ + "status", + "scheduled_at" + ], + "isUnique": false + }, + "idx_embedding_jobs_source_id": { + "name": "idx_embedding_jobs_source_id", + "columns": [ + "source", + "source_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "embedding_meta": { + "name": "embedding_meta", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "ghost_cards": { + "name": "ghost_cards", + "columns": { + "call_id": { + "name": "call_id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "ghost_id": { + "name": "ghost_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "html": { + "name": "html", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "height": { + "name": "height", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "v": { + "name": "v", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 1 + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "ghost_cards_updated_at_idx": { + "name": "ghost_cards_updated_at_idx", + "columns": [ + "updated_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "hook_group_context_cursors": { + "name": "hook_group_context_cursors", + "columns": { + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "cursor_key": { + "name": "cursor_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "cursor_id": { + "name": "cursor_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "hook_group_context_cursors_updated_at_idx": { + "name": "hook_group_context_cursors_updated_at_idx", + "columns": [ + "updated_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "hook_group_context_cursors_provider_cursor_key_pk": { + "columns": [ + "provider", + "cursor_key" + ], + "name": "hook_group_context_cursors_provider_cursor_key_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "hook_group_message_stats": { + "name": "hook_group_message_stats", + "columns": { + "provider": { + "name": "provider", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "row_count": { + "name": "row_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "text_bytes": { + "name": "text_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "hook_group_messages": { + "name": "hook_group_messages", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "chat_id": { + "name": "chat_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "thread_id": { + "name": "thread_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "message_id": { + "name": "message_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "chat_name": { + "name": "chat_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "author": { + "name": "author", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "is_bot": { + "name": "is_bot", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "file_names": { + "name": "file_names", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "sent_at": { + "name": "sent_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "hook_group_messages_msg_idx": { + "name": "hook_group_messages_msg_idx", + "columns": [ + "provider", + "chat_id", + "thread_id", + "message_id" + ], + "isUnique": true + }, + "hook_group_messages_window_idx": { + "name": "hook_group_messages_window_idx", + "columns": [ + "provider", + "chat_id", + "thread_id", + "id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "im_bindings": { + "name": "im_bindings", + "columns": { + "channel": { + "name": "channel", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "bot_context_id": { + "name": "bot_context_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "scope_key": { + "name": "scope_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "target_session_id": { + "name": "target_session_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "attached_at": { + "name": "attached_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "attached_via_card_message_id": { + "name": "attached_via_card_message_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "idx_im_bindings_target": { + "name": "idx_im_bindings_target", + "columns": [ + "target_session_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "im_bindings_target_session_id_sessions_id_fk": { + "name": "im_bindings_target_session_id_sessions_id_fk", + "tableFrom": "im_bindings", + "tableTo": "sessions", + "columnsFrom": [ + "target_session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "im_bindings_channel_bot_context_id_user_id_scope_key_pk": { + "columns": [ + "channel", + "bot_context_id", + "user_id", + "scope_key" + ], + "name": "im_bindings_channel_bot_context_id_user_id_scope_key_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "media_blobs": { + "name": "media_blobs", + "columns": { + "hash": { + "name": "hash", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "ext": { + "name": "ext", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "mime_type": { + "name": "mime_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "bytes": { + "name": "bytes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "is_cache": { + "name": "is_cache", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_access_at": { + "name": "last_access_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "media_invocations": { + "name": "media_invocations", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "owner": { + "name": "owner", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "model_id": { + "name": "model_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "capability": { + "name": "capability", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "guide_revision": { + "name": "guide_revision", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "guide_json": { + "name": "guide_json", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "response_json": { + "name": "response_json", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "media_invocations_owner_created_at_idx": { + "name": "media_invocations_owner_created_at_idx", + "columns": [ + "owner", + "created_at" + ], + "isUnique": false + }, + "media_invocations_owner_state_idx": { + "name": "media_invocations_owner_state_idx", + "columns": [ + "owner", + "state" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "media_refs": { + "name": "media_refs", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "hash": { + "name": "hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ref_kind": { + "name": "ref_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ref_id": { + "name": "ref_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "origin_session_id": { + "name": "origin_session_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "origin_kind": { + "name": "origin_kind", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "origin_id": { + "name": "origin_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "media_refs_hash_idx": { + "name": "media_refs_hash_idx", + "columns": [ + "hash" + ], + "isUnique": false + }, + "media_refs_ref_idx": { + "name": "media_refs_ref_idx", + "columns": [ + "ref_kind", + "ref_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "media_refs_hash_media_blobs_hash_fk": { + "name": "media_refs_hash_media_blobs_hash_fk", + "tableFrom": "media_refs", + "tableTo": "media_blobs", + "columnsFrom": [ + "hash" + ], + "columnsTo": [ + "hash" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "messages": { + "name": "messages", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tool_use_id": { + "name": "tool_use_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "agent_meta": { + "name": "agent_meta", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "agent_kind": { + "name": "agent_kind", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "rewind_at": { + "name": "rewind_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "uniq_messages_session_client": { + "name": "uniq_messages_session_client", + "columns": [ + "session_id", + "client_id" + ], + "isUnique": true + }, + "idx_messages_session_created": { + "name": "idx_messages_session_created", + "columns": [ + "session_id", + "created_at" + ], + "isUnique": false + }, + "idx_messages_created_at": { + "name": "idx_messages_created_at", + "columns": [ + "created_at", + "id" + ], + "isUnique": false + }, + "idx_messages_rewind_at": { + "name": "idx_messages_rewind_at", + "columns": [ + "rewind_at" + ], + "isUnique": false + }, + "idx_messages_active_error_tail": { + "name": "idx_messages_active_error_tail", + "columns": [ + "session_id", + "created_at" + ], + "isUnique": false, + "where": "\"messages\".\"role\" = 'error' AND \"messages\".\"rewind_at\" IS NULL" + } + }, + "foreignKeys": { + "messages_session_id_sessions_id_fk": { + "name": "messages_session_id_sessions_id_fk", + "tableFrom": "messages", + "tableTo": "sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "messages_fts_rows": { + "name": "messages_fts_rows", + "columns": { + "fts_rowid": { + "name": "fts_rowid", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "message_id": { + "name": "message_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "messages_fts_rows_message_id_idx": { + "name": "messages_fts_rows_message_id_idx", + "columns": [ + "message_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "migration_history": { + "name": "migration_history", + "columns": { + "seq": { + "name": "seq", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "content_hash": { + "name": "content_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "applied_at": { + "name": "applied_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "migration_meta": { + "name": "migration_meta", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "orca_teams": { + "name": "orca_teams", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "lead_session_id": { + "name": "lead_session_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'active'" + }, + "completed_at": { + "name": "completed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "uniq_active_team_per_lead": { + "name": "uniq_active_team_per_lead", + "columns": [ + "lead_session_id" + ], + "isUnique": true, + "where": "\"orca_teams\".\"status\" = 'active'" + }, + "idx_orca_teams_status": { + "name": "idx_orca_teams_status", + "columns": [ + "status" + ], + "isUnique": false + } + }, + "foreignKeys": { + "orca_teams_lead_session_id_sessions_id_fk": { + "name": "orca_teams_lead_session_id_sessions_id_fk", + "tableFrom": "orca_teams", + "tableTo": "sessions", + "columnsFrom": [ + "lead_session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "orca_worker_creation_reservations": { + "name": "orca_worker_creation_reservations", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "team_id": { + "name": "team_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "uniq_orca_worker_creation_reservations_team_label": { + "name": "uniq_orca_worker_creation_reservations_team_label", + "columns": [ + "team_id", + "lower(\"label\")" + ], + "isUnique": true + }, + "idx_orca_worker_creation_reservations_expires_at": { + "name": "idx_orca_worker_creation_reservations_expires_at", + "columns": [ + "expires_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "orca_worker_creation_reservations_team_id_orca_teams_id_fk": { + "name": "orca_worker_creation_reservations_team_id_orca_teams_id_fk", + "tableFrom": "orca_worker_creation_reservations", + "tableTo": "orca_teams", + "columnsFrom": [ + "team_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "orca_workers": { + "name": "orca_workers", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "team_id": { + "name": "team_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'idle'" + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "worktree_branch": { + "name": "worktree_branch", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'developer'" + }, + "focused": { + "name": "focused", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "idle_since": { + "name": "idle_since", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "uniq_orca_workers_session_id": { + "name": "uniq_orca_workers_session_id", + "columns": [ + "session_id" + ], + "isUnique": true + }, + "uniq_orca_workers_team_label": { + "name": "uniq_orca_workers_team_label", + "columns": [ + "team_id", + "lower(\"label\")" + ], + "isUnique": true + }, + "uniq_orca_workers_focused_per_team": { + "name": "uniq_orca_workers_focused_per_team", + "columns": [ + "team_id" + ], + "isUnique": true, + "where": "\"orca_workers\".\"focused\" = true" + }, + "idx_orca_workers_team_id": { + "name": "idx_orca_workers_team_id", + "columns": [ + "team_id" + ], + "isUnique": false + }, + "idx_orca_workers_status": { + "name": "idx_orca_workers_status", + "columns": [ + "status" + ], + "isUnique": false + } + }, + "foreignKeys": { + "orca_workers_team_id_orca_teams_id_fk": { + "name": "orca_workers_team_id_orca_teams_id_fk", + "tableFrom": "orca_workers", + "tableTo": "orca_teams", + "columnsFrom": [ + "team_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "orca_workers_session_id_sessions_id_fk": { + "name": "orca_workers_session_id_sessions_id_fk", + "tableFrom": "orca_workers", + "tableTo": "sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "project_aliases": { + "name": "project_aliases", + "columns": { + "project_key": { + "name": "project_key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "alias": { + "name": "alias", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "idx_project_aliases_updated_at": { + "name": "idx_project_aliases_updated_at", + "columns": [ + "updated_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "project_automation_consents": { + "name": "project_automation_consents", + "columns": { + "working_dir": { + "name": "working_dir", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "consented_at": { + "name": "consented_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "config_hash": { + "name": "config_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "recent_workdirs": { + "name": "recent_workdirs", + "columns": { + "path": { + "name": "path", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "last_used_at": { + "name": "last_used_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "idx_recent_workdirs_last_used_at": { + "name": "idx_recent_workdirs_last_used_at", + "columns": [ + "last_used_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "right_sidebar_tabs": { + "name": "right_sidebar_tabs", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "is_active": { + "name": "is_active", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'{}'" + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "right_sidebar_tabs_session_idx": { + "name": "right_sidebar_tabs_session_idx", + "columns": [ + "session_id", + "position" + ], + "isUnique": false + }, + "right_sidebar_tabs_subagents_singleton_idx": { + "name": "right_sidebar_tabs_subagents_singleton_idx", + "columns": [ + "session_id" + ], + "isUnique": true, + "where": "\"right_sidebar_tabs\".\"kind\" = 'subagents'" + } + }, + "foreignKeys": { + "right_sidebar_tabs_session_id_sessions_id_fk": { + "name": "right_sidebar_tabs_session_id_sessions_id_fk", + "tableFrom": "right_sidebar_tabs", + "tableTo": "sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "schedule_runs": { + "name": "schedule_runs", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "schedule_id": { + "name": "schedule_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "fired_at": { + "name": "fired_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "finished_at": { + "name": "finished_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "error_msg": { + "name": "error_msg", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cost_usd": { + "name": "cost_usd", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "estimated_value_usd": { + "name": "estimated_value_usd", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "cost_amount": { + "name": "cost_amount", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "estimated_value_amount": { + "name": "estimated_value_amount", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "cost_currency": { + "name": "cost_currency", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cost_is_approximate": { + "name": "cost_is_approximate", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "cost_attribution": { + "name": "cost_attribution", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'legacy'" + }, + "result_text": { + "name": "result_text", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pre_run_hook_result": { + "name": "pre_run_hook_result", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "read_at": { + "name": "read_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "heartbeat_at": { + "name": "heartbeat_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "idx_schedule_runs_schedule": { + "name": "idx_schedule_runs_schedule", + "columns": [ + "schedule_id", + "fired_at" + ], + "isUnique": false + }, + "idx_schedule_runs_running_schedule": { + "name": "idx_schedule_runs_running_schedule", + "columns": [ + "schedule_id" + ], + "isUnique": false, + "where": "\"schedule_runs\".\"status\" = 'running'" + }, + "idx_schedule_runs_running_heartbeat": { + "name": "idx_schedule_runs_running_heartbeat", + "columns": [ + "heartbeat_at" + ], + "isUnique": false, + "where": "\"schedule_runs\".\"status\" = 'running' AND \"schedule_runs\".\"heartbeat_at\" IS NOT NULL" + }, + "idx_schedule_runs_running_legacy": { + "name": "idx_schedule_runs_running_legacy", + "columns": [ + "fired_at" + ], + "isUnique": false, + "where": "\"schedule_runs\".\"status\" = 'running' AND \"schedule_runs\".\"heartbeat_at\" IS NULL" + }, + "idx_schedule_runs_unread_terminal": { + "name": "idx_schedule_runs_unread_terminal", + "columns": [ + "schedule_id", + "status", + "fired_at" + ], + "isUnique": false, + "where": "\"schedule_runs\".\"read_at\" IS NULL AND \"schedule_runs\".\"status\" IN ('success', 'failed', 'aborted', 'interrupted')" + }, + "idx_schedule_runs_session_latest": { + "name": "idx_schedule_runs_session_latest", + "columns": [ + "session_id", + "fired_at", + "id" + ], + "isUnique": false, + "where": "\"schedule_runs\".\"session_id\" IS NOT NULL" + } + }, + "foreignKeys": { + "schedule_runs_schedule_id_schedules_id_fk": { + "name": "schedule_runs_schedule_id_schedules_id_fk", + "tableFrom": "schedule_runs", + "tableTo": "schedules", + "columnsFrom": [ + "schedule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "schedule_runs_session_id_sessions_id_fk": { + "name": "schedule_runs_session_id_sessions_id_fk", + "tableFrom": "schedule_runs", + "tableTo": "sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "schedule_session_latest_runs": { + "name": "schedule_session_latest_runs", + "columns": { + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "run_id": { + "name": "run_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "fired_at": { + "name": "fired_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "idx_schedule_session_latest_runs_run": { + "name": "idx_schedule_session_latest_runs_run", + "columns": [ + "run_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "schedule_session_latest_runs_session_id_sessions_id_fk": { + "name": "schedule_session_latest_runs_session_id_sessions_id_fk", + "tableFrom": "schedule_session_latest_runs", + "tableTo": "sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "schedule_session_latest_runs_run_id_schedule_runs_id_fk": { + "name": "schedule_session_latest_runs_run_id_schedule_runs_id_fk", + "tableFrom": "schedule_session_latest_runs", + "tableTo": "schedule_runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "schedules": { + "name": "schedules", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "job_type": { + "name": "job_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'prompt'" + }, + "job_config": { + "name": "job_config", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "execution_mode": { + "name": "execution_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'agent'" + }, + "script_config": { + "name": "script_config", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": "'user'" + }, + "project_config_id": { + "name": "project_config_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "legacy_session_fallback": { + "name": "legacy_session_fallback", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'cron'" + }, + "cron_expr": { + "name": "cron_expr", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "recurring": { + "name": "recurring", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "manual": { + "name": "manual", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "interval_ms": { + "name": "interval_ms", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "agent_kind": { + "name": "agent_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "effort": { + "name": "effort", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "fast_mode": { + "name": "fast_mode", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "working_dir": { + "name": "working_dir", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "workspace_kind": { + "name": "workspace_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'project'" + }, + "use_worktree": { + "name": "use_worktree", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "target_session_id": { + "name": "target_session_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "persistent_session": { + "name": "persistent_session", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "silent_when_idle": { + "name": "silent_when_idle", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "pre_run_hook_command": { + "name": "pre_run_hook_command", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pre_run_hook_timeout_ms": { + "name": "pre_run_hook_timeout_ms", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "skip_log_session_id": { + "name": "skip_log_session_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "notify_desktop": { + "name": "notify_desktop", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "notify_feishu": { + "name": "notify_feishu", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "notify_wecom_group": { + "name": "notify_wecom_group", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'active'" + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_fired_at": { + "name": "last_fired_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_finished_at": { + "name": "last_finished_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "next_fire_at": { + "name": "next_fire_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expire_at": { + "name": "expire_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "idx_schedules_active_next": { + "name": "idx_schedules_active_next", + "columns": [ + "status", + "next_fire_at" + ], + "isUnique": false + }, + "idx_schedules_target_session": { + "name": "idx_schedules_target_session", + "columns": [ + "target_session_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "schedules_target_session_id_sessions_id_fk": { + "name": "schedules_target_session_id_sessions_id_fk", + "tableFrom": "schedules", + "tableTo": "sessions", + "columnsFrom": [ + "target_session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "schedules_skip_log_session_id_sessions_id_fk": { + "name": "schedules_skip_log_session_id_sessions_id_fk", + "tableFrom": "schedules", + "tableTo": "sessions", + "columnsFrom": [ + "skip_log_session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "session_goals": { + "name": "session_goals", + "columns": { + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "objective": { + "name": "objective", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'active'" + }, + "budget_tokens": { + "name": "budget_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "max_turns": { + "name": "max_turns", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "no_progress_limit": { + "name": "no_progress_limit", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "turns_used": { + "name": "turns_used", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "tokens_used": { + "name": "tokens_used", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "no_progress_streak": { + "name": "no_progress_streak", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "usage_reset_at": { + "name": "usage_reset_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_reason": { + "name": "last_reason", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "agent_kind": { + "name": "agent_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "started_at": { + "name": "started_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "idx_session_goals_status": { + "name": "idx_session_goals_status", + "columns": [ + "status" + ], + "isUnique": false + } + }, + "foreignKeys": { + "session_goals_session_id_sessions_id_fk": { + "name": "session_goals_session_id_sessions_id_fk", + "tableFrom": "session_goals", + "tableTo": "sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "session_pr_refs": { + "name": "session_pr_refs", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "owner": { + "name": "owner", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "repo": { + "name": "repo", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "pr_number": { + "name": "pr_number", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "first_seen_at": { + "name": "first_seen_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "uniq_session_pr_refs": { + "name": "uniq_session_pr_refs", + "columns": [ + "session_id", + "owner", + "repo", + "pr_number" + ], + "isUnique": true + }, + "idx_session_pr_refs_session_last_seen": { + "name": "idx_session_pr_refs_session_last_seen", + "columns": [ + "session_id", + "last_seen_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "session_pr_refs_session_id_sessions_id_fk": { + "name": "session_pr_refs_session_id_sessions_id_fk", + "tableFrom": "session_pr_refs", + "tableTo": "sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sessions": { + "name": "sessions", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'New Maker'" + }, + "working_dir": { + "name": "working_dir", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "workspace_kind": { + "name": "workspace_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'project'" + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'claude-sonnet-4-6'" + }, + "effort": { + "name": "effort", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'high'" + }, + "permission_mode": { + "name": "permission_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'ask'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'active'" + }, + "sdk_session_id": { + "name": "sdk_session_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "total_token_usage": { + "name": "total_token_usage", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "total_cost_usd": { + "name": "total_cost_usd", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "total_cost_amount": { + "name": "total_cost_amount", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "total_cost_currency": { + "name": "total_cost_currency", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "total_cost_is_approximate": { + "name": "total_cost_is_approximate", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "context_tokens": { + "name": "context_tokens", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "context_window": { + "name": "context_window", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "fast_mode": { + "name": "fast_mode", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "plan_mode_enabled": { + "name": "plan_mode_enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "cleared_at": { + "name": "cleared_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "maintenance_cleared_at": { + "name": "maintenance_cleared_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pinned_at": { + "name": "pinned_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "user_send_at": { + "name": "user_send_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "agent_kind": { + "name": "agent_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'cc'" + }, + "orca_role": { + "name": "orca_role", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "parent_session_id": { + "name": "parent_session_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "forked_at_message_id": { + "name": "forked_at_message_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "worktree_path": { + "name": "worktree_path", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'desktop'" + }, + "feishu_open_id": { + "name": "feishu_open_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "feishu_bot_app_id": { + "name": "feishu_bot_app_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "im_bot_context_id": { + "name": "im_bot_context_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "im_user_id": { + "name": "im_user_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "used_project_context": { + "name": "used_project_context", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "codex_history_has_product_prompt": { + "name": "codex_history_has_product_prompt", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "codex_plan_json": { + "name": "codex_plan_json", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "extra_dirs": { + "name": "extra_dirs", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "writable_dirs": { + "name": "writable_dirs", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "remote_host_id": { + "name": "remote_host_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "active_turn_started_at": { + "name": "active_turn_started_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "active_turn_pid": { + "name": "active_turn_pid", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_turn_ended_at": { + "name": "last_turn_ended_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "list_preview": { + "name": "list_preview", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "list_preview_role": { + "name": "list_preview_role", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "list_message_count": { + "name": "list_message_count", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "idx_sessions_updated_at": { + "name": "idx_sessions_updated_at", + "columns": [ + "updated_at" + ], + "isUnique": false + }, + "idx_sessions_user_send_at": { + "name": "idx_sessions_user_send_at", + "columns": [ + "user_send_at" + ], + "isUnique": false + }, + "idx_sessions_sdk_session_id": { + "name": "idx_sessions_sdk_session_id", + "columns": [ + "sdk_session_id" + ], + "isUnique": false + }, + "idx_sessions_workdir_created": { + "name": "idx_sessions_workdir_created", + "columns": [ + "working_dir", + "created_at", + "id" + ], + "isUnique": false + }, + "idx_sessions_created_at": { + "name": "idx_sessions_created_at", + "columns": [ + "created_at", + "id" + ], + "isUnique": false + }, + "idx_sessions_workspace_kind": { + "name": "idx_sessions_workspace_kind", + "columns": [ + "workspace_kind" + ], + "isUnique": false + }, + "idx_sessions_parent_session_id": { + "name": "idx_sessions_parent_session_id", + "columns": [ + "parent_session_id" + ], + "isUnique": false + }, + "idx_sessions_orca_role": { + "name": "idx_sessions_orca_role", + "columns": [ + "orca_role" + ], + "isUnique": false + }, + "idx_sessions_worktree_path": { + "name": "idx_sessions_worktree_path", + "columns": [ + "worktree_path" + ], + "isUnique": false + }, + "idx_sessions_feishu_lookup": { + "name": "idx_sessions_feishu_lookup", + "columns": [ + "source", + "feishu_bot_app_id", + "feishu_open_id" + ], + "isUnique": false + }, + "idx_sessions_im_lookup": { + "name": "idx_sessions_im_lookup", + "columns": [ + "source", + "im_bot_context_id", + "im_user_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "sessions_parent_session_id_sessions_id_fk": { + "name": "sessions_parent_session_id_sessions_id_fk", + "tableFrom": "sessions", + "tableTo": "sessions", + "columnsFrom": [ + "parent_session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "skill_usage_exposures": { + "name": "skill_usage_exposures", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "analyzer_version": { + "name": "analyzer_version", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'6'" + }, + "raw_file_path": { + "name": "raw_file_path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "raw_line_no": { + "name": "raw_line_no", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sdk_session_id": { + "name": "sdk_session_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_kind": { + "name": "agent_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "skill_name": { + "name": "skill_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "skill_path": { + "name": "skill_path", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "skill_document_hash": { + "name": "skill_document_hash", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "exposure_content_hash": { + "name": "exposure_content_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "document_hash_source": { + "name": "document_hash_source", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tool_use_id": { + "name": "tool_use_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "seen_at": { + "name": "seen_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "tool_call_count": { + "name": "tool_call_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "repeated_tool_call_count": { + "name": "repeated_tool_call_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "tool_error_count": { + "name": "tool_error_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "command_call_count": { + "name": "command_call_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "command_failure_count": { + "name": "command_failure_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + } + }, + "indexes": { + "idx_skill_usage_exposures_skill_document_version": { + "name": "idx_skill_usage_exposures_skill_document_version", + "columns": [ + "analyzer_version", + "skill_name", + "skill_document_hash" + ], + "isUnique": false + }, + "idx_skill_usage_exposures_session": { + "name": "idx_skill_usage_exposures_session", + "columns": [ + "session_id" + ], + "isUnique": false + }, + "idx_skill_usage_exposures_raw_file": { + "name": "idx_skill_usage_exposures_raw_file", + "columns": [ + "raw_file_path" + ], + "isUnique": false + } + }, + "foreignKeys": { + "skill_usage_exposures_raw_file_path_skill_usage_sources_raw_file_path_fk": { + "name": "skill_usage_exposures_raw_file_path_skill_usage_sources_raw_file_path_fk", + "tableFrom": "skill_usage_exposures", + "tableTo": "skill_usage_sources", + "columnsFrom": [ + "raw_file_path" + ], + "columnsTo": [ + "raw_file_path" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "skill_usage_sources": { + "name": "skill_usage_sources", + "columns": { + "raw_file_path": { + "name": "raw_file_path", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "analyzer_version": { + "name": "analyzer_version", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'6'" + }, + "agent_kind": { + "name": "agent_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sdk_session_id": { + "name": "sdk_session_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "mtime_ms": { + "name": "mtime_ms", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "size_bytes": { + "name": "size_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "last_scanned_at": { + "name": "last_scanned_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'ok'" + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "idx_skill_usage_sources_session": { + "name": "idx_skill_usage_sources_session", + "columns": [ + "session_id" + ], + "isUnique": false + }, + "idx_skill_usage_sources_sdk_session": { + "name": "idx_skill_usage_sources_sdk_session", + "columns": [ + "sdk_session_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "subagent_run_aliases": { + "name": "subagent_run_aliases", + "columns": { + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "alias": { + "name": "alias", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "run_id": { + "name": "run_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "subagent_run_aliases_lookup_idx": { + "name": "subagent_run_aliases_lookup_idx", + "columns": [ + "session_id", + "provider", + "alias", + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "subagent_run_aliases_session_id_sessions_id_fk": { + "name": "subagent_run_aliases_session_id_sessions_id_fk", + "tableFrom": "subagent_run_aliases", + "tableTo": "sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "subagent_run_aliases_run_id_subagent_runs_id_fk": { + "name": "subagent_run_aliases_run_id_subagent_runs_id_fk", + "tableFrom": "subagent_run_aliases", + "tableTo": "subagent_runs", + "columnsFrom": [ + "run_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "subagent_run_aliases_run_id_alias_pk": { + "columns": [ + "run_id", + "alias" + ], + "name": "subagent_run_aliases_run_id_alias_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "subagent_runs": { + "name": "subagent_runs", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "logical_agent_id": { + "name": "logical_agent_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "parent_tool_use_id": { + "name": "parent_tool_use_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "aliases": { + "name": "aliases", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "provider_run_ids": { + "name": "provider_run_ids", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'running'" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "returned_result": { + "name": "returned_result", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "returned_result_empty": { + "name": "returned_result_empty", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "returned_result_truncated": { + "name": "returned_result_truncated", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "reasoning_effort": { + "name": "reasoning_effort", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "total_tokens": { + "name": "total_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tool_uses": { + "name": "tool_uses", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "duration_ms": { + "name": "duration_ms", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "cost_usd": { + "name": "cost_usd", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "capabilities": { + "name": "capabilities", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'{}'" + }, + "activity": { + "name": "activity", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "started_at": { + "name": "started_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ended_at": { + "name": "ended_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "rewind_at": { + "name": "rewind_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "subagent_runs_logical_idx": { + "name": "subagent_runs_logical_idx", + "columns": [ + "session_id", + "provider", + "logical_agent_id" + ], + "isUnique": false + }, + "subagent_runs_session_idx": { + "name": "subagent_runs_session_idx", + "columns": [ + "session_id", + "rewind_at", + "deleted_at", + "started_at" + ], + "isUnique": false + }, + "subagent_runs_parent_tool_use_idx": { + "name": "subagent_runs_parent_tool_use_idx", + "columns": [ + "session_id", + "parent_tool_use_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "subagent_runs_session_id_sessions_id_fk": { + "name": "subagent_runs_session_id_sessions_id_fk", + "tableFrom": "subagent_runs", + "tableTo": "sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "vec_table_meta": { + "name": "vec_table_meta", + "columns": { + "vec_table": { + "name": "vec_table", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "model_id": { + "name": "model_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "dim": { + "name": "dim", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "registered_at": { + "name": "registered_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "wechat_file_attachments": { + "name": "wechat_file_attachments", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "binding_epoch": { + "name": "binding_epoch", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "abs_path": { + "name": "abs_path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "original_name": { + "name": "original_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "mime_type": { + "name": "mime_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "bytes": { + "name": "bytes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'staged'" + }, + "promoted_at": { + "name": "promoted_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "idx_wechat_file_attachments_task": { + "name": "idx_wechat_file_attachments_task", + "columns": [ + "binding_epoch", + "task_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "wechat_file_attachments_binding_epoch_wechat_sync_state_binding_epoch_fk": { + "name": "wechat_file_attachments_binding_epoch_wechat_sync_state_binding_epoch_fk", + "tableFrom": "wechat_file_attachments", + "tableTo": "wechat_sync_state", + "columnsFrom": [ + "binding_epoch" + ], + "columnsTo": [ + "binding_epoch" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "wechat_file_attachments_task_id_wechat_inbox_id_fk": { + "name": "wechat_file_attachments_task_id_wechat_inbox_id_fk", + "tableFrom": "wechat_file_attachments", + "tableTo": "wechat_inbox", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "wechat_file_attachments_session_id_sessions_id_fk": { + "name": "wechat_file_attachments_session_id_sessions_id_fk", + "tableFrom": "wechat_file_attachments", + "tableTo": "sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "wechat_inbox": { + "name": "wechat_inbox", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "binding_epoch": { + "name": "binding_epoch", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "platform_message_id": { + "name": "platform_message_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "platform_seq": { + "name": "platform_seq", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "peer_id": { + "name": "peer_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "received_at": { + "name": "received_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "platform_created_at": { + "name": "platform_created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "lease_until": { + "name": "lease_until", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "conversation_epoch": { + "name": "conversation_epoch", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "payload_json": { + "name": "payload_json", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "context_nonce": { + "name": "context_nonce", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "context_ciphertext": { + "name": "context_ciphertext", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "context_tag": { + "name": "context_tag", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "last_error_code": { + "name": "last_error_code", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "uniq_wechat_inbox_platform_message": { + "name": "uniq_wechat_inbox_platform_message", + "columns": [ + "binding_epoch", + "platform_message_id" + ], + "isUnique": true + }, + "idx_wechat_inbox_queue": { + "name": "idx_wechat_inbox_queue", + "columns": [ + "binding_epoch", + "status", + "received_at" + ], + "isUnique": false + }, + "idx_wechat_inbox_lease": { + "name": "idx_wechat_inbox_lease", + "columns": [ + "binding_epoch", + "lease_until" + ], + "isUnique": false + }, + "idx_wechat_inbox_conversation": { + "name": "idx_wechat_inbox_conversation", + "columns": [ + "binding_epoch", + "peer_id", + "conversation_epoch" + ], + "isUnique": false + }, + "uniq_wechat_inbox_running_session": { + "name": "uniq_wechat_inbox_running_session", + "columns": [ + "binding_epoch", + "session_id" + ], + "isUnique": true, + "where": "\"wechat_inbox\".\"session_id\" IS NOT NULL AND \"wechat_inbox\".\"status\" IN ('dispatching', 'accepted_running', 'waiting_desktop', 'delivery_pending')" + } + }, + "foreignKeys": { + "wechat_inbox_binding_epoch_wechat_sync_state_binding_epoch_fk": { + "name": "wechat_inbox_binding_epoch_wechat_sync_state_binding_epoch_fk", + "tableFrom": "wechat_inbox", + "tableTo": "wechat_sync_state", + "columnsFrom": [ + "binding_epoch" + ], + "columnsTo": [ + "binding_epoch" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "wechat_inbox_session_id_sessions_id_fk": { + "name": "wechat_inbox_session_id_sessions_id_fk", + "tableFrom": "wechat_inbox", + "tableTo": "sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "wechat_outbox": { + "name": "wechat_outbox", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "binding_epoch": { + "name": "binding_epoch", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "chunk_index": { + "name": "chunk_index", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "media_json": { + "name": "media_json", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "next_retry_at": { + "name": "next_retry_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "delivered_at": { + "name": "delivered_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "uniq_wechat_outbox_client_id": { + "name": "uniq_wechat_outbox_client_id", + "columns": [ + "binding_epoch", + "client_id" + ], + "isUnique": true + }, + "idx_wechat_outbox_delivery": { + "name": "idx_wechat_outbox_delivery", + "columns": [ + "binding_epoch", + "status", + "next_retry_at" + ], + "isUnique": false + }, + "idx_wechat_outbox_task": { + "name": "idx_wechat_outbox_task", + "columns": [ + "binding_epoch", + "task_id", + "chunk_index" + ], + "isUnique": false + } + }, + "foreignKeys": { + "wechat_outbox_binding_epoch_wechat_sync_state_binding_epoch_fk": { + "name": "wechat_outbox_binding_epoch_wechat_sync_state_binding_epoch_fk", + "tableFrom": "wechat_outbox", + "tableTo": "wechat_sync_state", + "columnsFrom": [ + "binding_epoch" + ], + "columnsTo": [ + "binding_epoch" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "wechat_outbox_task_id_wechat_inbox_id_fk": { + "name": "wechat_outbox_task_id_wechat_inbox_id_fk", + "tableFrom": "wechat_outbox", + "tableTo": "wechat_inbox", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "wechat_sync_state": { + "name": "wechat_sync_state", + "columns": { + "binding_epoch": { + "name": "binding_epoch", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "is_active": { + "name": "is_active", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "sync_cursor": { + "name": "sync_cursor", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "last_poll_at": { + "name": "last_poll_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_error_code": { + "name": "last_error_code", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "uniq_wechat_sync_active": { + "name": "uniq_wechat_sync_active", + "columns": [ + "is_active" + ], + "isUnique": true, + "where": "\"wechat_sync_state\".\"is_active\" = 1" + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": { + "uniq_orca_worker_creation_reservations_team_label": { + "columns": { + "lower(\"label\")": { + "isExpression": true + } + } + }, + "uniq_orca_workers_team_label": { + "columns": { + "lower(\"label\")": { + "isExpression": true + } + } + } + } + } +} \ No newline at end of file diff --git a/apps/desktop/drizzle/meta/_journal.json b/apps/desktop/drizzle/meta/_journal.json index 88186696712..f897a955170 100644 --- a/apps/desktop/drizzle/meta/_journal.json +++ b/apps/desktop/drizzle/meta/_journal.json @@ -708,6 +708,13 @@ "when": 1787992937440, "tag": "0100_segment_messages_fts_cjk", "breakpoints": true + }, + { + "idx": 101, + "version": "6", + "when": 1788308528378, + "tag": "0101_furry_garia", + "breakpoints": true } ] } \ No newline at end of file diff --git a/apps/desktop/drizzle/scripts/0101_furry_garia.ts b/apps/desktop/drizzle/scripts/0101_furry_garia.ts new file mode 100644 index 00000000000..bd96da1596a --- /dev/null +++ b/apps/desktop/drizzle/scripts/0101_furry_garia.ts @@ -0,0 +1,13 @@ +import type Database from 'better-sqlite3'; + +function run(db: Database.Database): void { + const columns = db + .prepare("PRAGMA table_info('sessions')") + .all() + .map((row) => String((row as { name: unknown }).name)); + if (!columns.includes('maintenance_cleared_at')) { + db.exec('ALTER TABLE sessions ADD COLUMN maintenance_cleared_at integer'); + } +} + +module.exports = { run }; diff --git a/apps/desktop/src/main/localDb/__tests__/dbSlimmingMaintenance.test.ts b/apps/desktop/src/main/localDb/__tests__/dbSlimmingMaintenance.test.ts index a0bff6a676c..12a2c04836c 100644 --- a/apps/desktop/src/main/localDb/__tests__/dbSlimmingMaintenance.test.ts +++ b/apps/desktop/src/main/localDb/__tests__/dbSlimmingMaintenance.test.ts @@ -77,6 +77,7 @@ function createCleanupFixture(): void { context_tokens INTEGER NOT NULL DEFAULT 0, context_window INTEGER NOT NULL DEFAULT 0, cleared_at INTEGER, + maintenance_cleared_at INTEGER, summary TEXT, codex_plan_json TEXT, codex_history_has_product_prompt INTEGER, @@ -349,7 +350,7 @@ describe('runDbSlimmingMaintenance', () => { db.prepare(` SELECT title, status, updated_at, total_token_usage, total_cost_usd, sdk_session_id, list_preview, list_preview_role, list_message_count, - context_tokens, context_window, cleared_at, + context_tokens, context_window, cleared_at, maintenance_cleared_at, summary, codex_plan_json, codex_history_has_product_prompt, active_turn_started_at, last_turn_ended_at FROM sessions WHERE id = 'archived-boundary' @@ -367,6 +368,7 @@ describe('runDbSlimmingMaintenance', () => { context_tokens: 100, context_window: 200, cleared_at: null, + maintenance_cleared_at: 2_000, summary: 'summary', codex_plan_json: '{}', codex_history_has_product_prompt: 1, @@ -376,7 +378,7 @@ describe('runDbSlimmingMaintenance', () => { expect( db.prepare(` SELECT sdk_session_id, list_preview, list_preview_role, list_message_count, - cleared_at, codex_plan_json + cleared_at, maintenance_cleared_at, codex_plan_json FROM sessions WHERE id = 'active-old' `).get(), ).toEqual({ @@ -385,6 +387,7 @@ describe('runDbSlimmingMaintenance', () => { list_preview_role: 'assistant', list_message_count: 1, cleared_at: 50, + maintenance_cleared_at: null, codex_plan_json: '{}', }); } finally { @@ -477,7 +480,7 @@ describe('runDbSlimmingMaintenance', () => { expect( db.prepare(` SELECT status, updated_at, sdk_session_id, list_preview, list_preview_role, - list_message_count, cleared_at, codex_plan_json, summary + list_message_count, cleared_at, maintenance_cleared_at, codex_plan_json, summary FROM sessions WHERE id = 'active-old' `).get(), ).toEqual({ @@ -488,13 +491,14 @@ describe('runDbSlimmingMaintenance', () => { list_preview_role: null, list_message_count: null, cleared_at: 2_000, + maintenance_cleared_at: 2_000, codex_plan_json: null, summary: null, }); expect( db.prepare(` SELECT updated_at, sdk_session_id, list_preview, list_preview_role, - list_message_count, cleared_at, codex_plan_json, summary + list_message_count, cleared_at, maintenance_cleared_at, codex_plan_json, summary FROM sessions WHERE id = 'active-updated-after-scan' `).get(), ).toEqual({ @@ -504,6 +508,7 @@ describe('runDbSlimmingMaintenance', () => { list_preview_role: 'assistant', list_message_count: 1, cleared_at: null, + maintenance_cleared_at: null, codex_plan_json: '{}', summary: 'summary', }); diff --git a/apps/desktop/src/main/localDb/__tests__/sessionListProjection.test.ts b/apps/desktop/src/main/localDb/__tests__/sessionListProjection.test.ts index 2dbc4913aa2..6bf8c655e59 100644 --- a/apps/desktop/src/main/localDb/__tests__/sessionListProjection.test.ts +++ b/apps/desktop/src/main/localDb/__tests__/sessionListProjection.test.ts @@ -132,6 +132,7 @@ describe('sessionToCamel list preview cache', () => { fastMode: false, planModeEnabled: false, clearedAt: null, + maintenanceClearedAt: 123, pinnedAt: null, userSendAt: null, agentKind: 'cc', @@ -158,6 +159,7 @@ describe('sessionToCamel list preview cache', () => { } as SessionRowWithCount); expect(session.preview).toBe('cached preview'); expect(session._count?.messages).toBe(4); + expect(session.maintenanceClearedAt).toBe('1970-01-01T00:00:00.123Z'); }); it('sanitizes cached listPreview the same way as SQL extracts', () => { diff --git a/apps/desktop/src/main/localDb/dbSlimmingMaintenance.ts b/apps/desktop/src/main/localDb/dbSlimmingMaintenance.ts index 14d8962777a..ab690cc010c 100644 --- a/apps/desktop/src/main/localDb/dbSlimmingMaintenance.ts +++ b/apps/desktop/src/main/localDb/dbSlimmingMaintenance.ts @@ -710,6 +710,15 @@ function compactWorkingCopy( WHERE id IN (SELECT id FROM temp.db_slimming_targets)`, ); } + if (sessionColumns.has('maintenance_cleared_at')) { + activeDb + .prepare( + `UPDATE sessions + SET maintenance_cleared_at = MAX(COALESCE(maintenance_cleared_at, 0), ?) + WHERE id IN (SELECT id FROM temp.db_slimming_targets)`, + ) + .run(Math.floor(request.scannedAt)); + } if (request.includeActiveTasks === true) { if (tableExists(activeDb, 'session_goals')) { activeDb.exec( diff --git a/apps/desktop/src/main/localDb/mapper.ts b/apps/desktop/src/main/localDb/mapper.ts index b4ddc3e0995..cb087012033 100644 --- a/apps/desktop/src/main/localDb/mapper.ts +++ b/apps/desktop/src/main/localDb/mapper.ts @@ -96,7 +96,9 @@ export function setSessionRuntimeProjector(projector: SessionRuntimeProjector | * 提炼成 `Session.preview` 纯文本。两字段可选——单字段 bump 等不带它们的路径 * preview 落 null,渲染端兜底隐藏。 */ -export type SessionRowWithCount = SessionRow & { +export type SessionRowWithCount = Omit & { + /** Optional for legacy/manual projections; current local rows always include it. */ + maintenanceClearedAt?: number | null; messageCount: number; latestMessageContent?: string | null; latestMessageExtract?: string | null; @@ -232,6 +234,7 @@ export function sessionToCamel(row: SessionRowWithCount): Session { fastMode: !!row.fastMode, planModeEnabled: !!row.planModeEnabled, clearedAt: msToIso(row.clearedAt), + maintenanceClearedAt: msToIso(row.maintenanceClearedAt), pinnedAt: msToIso(row.pinnedAt), userSendAt: msToIso(row.userSendAt), agentKind: row.agentKind as AgentKind, @@ -364,6 +367,7 @@ export function sessionCreateToRow( // 计划模式默认 OFF;草稿里开了计划模式的会话显式传 true。 planModeEnabled: !!body?.planModeEnabled, clearedAt: null, + maintenanceClearedAt: null, pinnedAt: null, userSendAt: null, agentKind: body?.agentKind ?? 'cc', diff --git a/apps/desktop/src/main/localDb/schema.ts b/apps/desktop/src/main/localDb/schema.ts index 9cf8ff86376..3baa738eb32 100644 --- a/apps/desktop/src/main/localDb/schema.ts +++ b/apps/desktop/src/main/localDb/schema.ts @@ -87,6 +87,12 @@ export const sessions = sqliteTable( */ planModeEnabled: integer('plan_mode_enabled', { mode: 'boolean' }).notNull().default(false), clearedAt: integer('cleared_at'), // unix ms + /** + * Database slimming physically removed this session's persisted history. + * Kept separate from clearedAt: /clear is a logical visibility boundary + * that also participates in resume/import behavior. + */ + maintenanceClearedAt: integer('maintenance_cleared_at'), // unix ms pinnedAt: integer('pinned_at'), // unix ms /** * 任务现状一句话摘要(仅置顶段卡片模式展示/生成)。 diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx index f35980f5a74..4cf64ab4d2a 100644 --- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx +++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx @@ -4315,7 +4315,7 @@ export function CCAgentSessionView({ workingDir={session?.workingDir ?? ''} messages={messages} historyLoaded={historyLoaded} - historyCleared={Boolean(session?.clearedAt)} + historyCleared={Boolean(session?.clearedAt || session?.maintenanceClearedAt)} taskUpdates={taskUpdates} isSessionStreaming={isStreaming} continuationTurnClientId={continuationTurnClientId} diff --git a/apps/desktop/src/renderer/lib/ccAgent.types.ts b/apps/desktop/src/renderer/lib/ccAgent.types.ts index fc0c656b534..7569ff53c2f 100644 --- a/apps/desktop/src/renderer/lib/ccAgent.types.ts +++ b/apps/desktop/src/renderer/lib/ccAgent.types.ts @@ -235,6 +235,11 @@ export interface Session { */ planModeEnabled?: boolean; clearedAt: string | null; // ISO 8601 — messages before this timestamp are hidden + /** + * ISO timestamp of the latest database-slimming pass that physically removed + * this session's history. Optional for payloads from older Desktop peers. + */ + maintenanceClearedAt?: string | null; pinnedAt: string | null; // ISO 8601 — when pinned, null = not pinned /** * 用户最近一次"按下发送"的时刻(ISO 8601,null = 从未发过)。