Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(sessions): advance recent activity on work handoffs
fmfsaisai59f3aca4f959
diff --git a/apps/desktop/drizzle/0131_amused_puff_adder.sql b/apps/desktop/drizzle/0131_amused_puff_adder.sqlnew file mode 100644index 0000000000..fdf6b6e5bd--- /dev/null+++ b/apps/desktop/drizzle/0131_amused_puff_adder.sql@@ -0,0 +1 @@+ALTER TABLE `sessions` ADD `last_activity_at` integer;\ No newline at end of filediff --git a/apps/desktop/drizzle/meta/0131_snapshot.json b/apps/desktop/drizzle/meta/0131_snapshot.jsonnew file mode 100644index 0000000000..eebb5d3166--- /dev/null+++ b/apps/desktop/drizzle/meta/0131_snapshot.json@@ -0,0 +1,7222 @@+{+ "version": "6",+ "dialect": "sqlite",+ "id": "b05d3986-bbff-4d57-bb16-d71d46d827bd",+ "prevId": "a9590771-933e-4d44-a046-c52e69437fb4",+ "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": {}+ },+ "auto_review_projections": {+ "name": "auto_review_projections",+ "columns": {+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "lead_id": {+ "name": "lead_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "revision": {+ "name": "revision",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "projected_revision": {+ "name": "projected_revision",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": -1+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 1+ },+ "payload": {+ "name": "payload",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "auto_review_projections_lead_idx": {+ "name": "auto_review_projections_lead_idx",+ "columns": [+ "lead_id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "auto_review_projections_session_id_sessions_id_fk": {+ "name": "auto_review_projections_session_id_sessions_id_fk",+ "tableFrom": "auto_review_projections",+ "tableTo": "sessions",+ "columnsFrom": [+ "session_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "auto_review_projections_lead_id_sessions_id_fk": {+ "name": "auto_review_projections_lead_id_sessions_id_fk",+ "tableFrom": "auto_review_projections",+ "tableTo": "sessions",+ "columnsFrom": [+ "lead_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "auto_review_projections_session_id_lead_id_pk": {+ "columns": [+ "session_id",+ "lead_id"+ ],+ "name": "auto_review_projections_session_id_lead_id_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "bot_delegations": {+ "name": "bot_delegations",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "requesting_bot_id": {+ "name": "requesting_bot_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "target_bot_id": {+ "name": "target_bot_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "parent_session_id": {+ "name": "parent_session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "child_session_id": {+ "name": "child_session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "objective": {+ "name": "objective",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "context_refs_json": {+ "name": "context_refs_json",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'[]'"+ },+ "artifact_refs_json": {+ "name": "artifact_refs_json",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'[]'"+ },+ "permission_snapshot_json": {+ "name": "permission_snapshot_json",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'{}'"+ },+ "group_task_posts_json": {+ "name": "group_task_posts_json",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'{}'"+ },+ "lineage_json": {+ "name": "lineage_json",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'[]'"+ },+ "target_profile_version": {+ "name": "target_profile_version",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "depth": {+ "name": "depth",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 1+ },+ "budget_tokens": {+ "name": "budget_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "tokens_used": {+ "name": "tokens_used",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'queued'"+ },+ "result_summary": {+ "name": "result_summary",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "output_artifacts_json": {+ "name": "output_artifacts_json",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'[]'"+ },+ "pending_interaction_json": {+ "name": "pending_interaction_json",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "run_sequence": {+ "name": "run_sequence",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 1+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "accepted_at": {+ "name": "accepted_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "completed_at": {+ "name": "completed_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "completion_delivered_at": {+ "name": "completion_delivered_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "idx_bot_delegations_requester_status": {+ "name": "idx_bot_delegations_requester_status",+ "columns": [+ "requesting_bot_id",+ "status"+ ],+ "isUnique": false+ },+ "idx_bot_delegations_target_status": {+ "name": "idx_bot_delegations_target_status",+ "columns": [+ "target_bot_id",+ "status"+ ],+ "isUnique": false+ },+ "idx_bot_delegations_parent_session": {+ "name": "idx_bot_delegations_parent_session",+ "columns": [+ "parent_session_id"+ ],+ "isUnique": false+ },+ "uniq_bot_delegations_child_session": {+ "name": "uniq_bot_delegations_child_session",+ "columns": [+ "child_session_id"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "bot_delegations_requesting_bot_id_bot_profiles_id_fk": {+ "name": "bot_delegations_requesting_bot_id_bot_profiles_id_fk",+ "tableFrom": "bot_delegations",+ "tableTo": "bot_profiles",+ "columnsFrom": [+ "requesting_bot_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "bot_delegations_target_bot_id_bot_profiles_id_fk": {+ "name": "bot_delegations_target_bot_id_bot_profiles_id_fk",+ "tableFrom": "bot_delegations",+ "tableTo": "bot_profiles",+ "columnsFrom": [+ "target_bot_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "bot_delegations_parent_session_id_sessions_id_fk": {+ "name": "bot_delegations_parent_session_id_sessions_id_fk",+ "tableFrom": "bot_delegations",+ "tableTo": "sessions",+ "columnsFrom": [+ "parent_session_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "bot_delegations_child_session_id_sessions_id_fk": {+ "name": "bot_delegations_child_session_id_sessions_id_fk",+ "tableFrom": "bot_delegations",+ "tableTo": "sessions",+ "columnsFrom": [+ "child_session_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "bot_direct_message_threads": {+ "name": "bot_direct_message_threads",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "bot_a_id": {+ "name": "bot_a_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "bot_b_id": {+ "name": "bot_b_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'active'"+ },+ "close_reason": {+ "name": "close_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "message_count": {+ "name": "message_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "max_messages": {+ "name": "max_messages",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "blocked_until": {+ "name": "blocked_until",+ "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+ },+ "closed_at": {+ "name": "closed_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "uniq_bot_dm_threads_active_pair": {+ "name": "uniq_bot_dm_threads_active_pair",+ "columns": [+ "bot_a_id",+ "bot_b_id"+ ],+ "isUnique": true,+ "where": "\"bot_direct_message_threads\".\"status\" = 'active'"+ },+ "idx_bot_dm_threads_pair_updated": {+ "name": "idx_bot_dm_threads_pair_updated",+ "columns": [+ "bot_a_id",+ "bot_b_id",+ "updated_at"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "bot_direct_messages": {+ "name": "bot_direct_messages",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "sequence": {+ "name": "sequence",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "sender_bot_id": {+ "name": "sender_bot_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "recipient_bot_id": {+ "name": "recipient_bot_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "sender_session_id": {+ "name": "sender_session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "recipient_session_id": {+ "name": "recipient_session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "delivery_status": {+ "name": "delivery_status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'pending'"+ },+ "sender_name": {+ "name": "sender_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "recipient_name": {+ "name": "recipient_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "bridge_session_id": {+ "name": "bridge_session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "uniq_bot_direct_messages_thread_sequence": {+ "name": "uniq_bot_direct_messages_thread_sequence",+ "columns": [+ "thread_id",+ "sequence"+ ],+ "isUnique": true+ },+ "idx_bot_direct_messages_thread_created": {+ "name": "idx_bot_direct_messages_thread_created",+ "columns": [+ "thread_id",+ "created_at"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "bot_direct_messages_thread_id_bot_direct_message_threads_id_fk": {+ "name": "bot_direct_messages_thread_id_bot_direct_message_threads_id_fk",+ "tableFrom": "bot_direct_messages",+ "tableTo": "bot_direct_message_threads",+ "columnsFrom": [+ "thread_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "bot_direct_messages_sender_session_id_sessions_id_fk": {+ "name": "bot_direct_messages_sender_session_id_sessions_id_fk",+ "tableFrom": "bot_direct_messages",+ "tableTo": "sessions",+ "columnsFrom": [+ "sender_session_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "bot_direct_messages_recipient_session_id_sessions_id_fk": {+ "name": "bot_direct_messages_recipient_session_id_sessions_id_fk",+ "tableFrom": "bot_direct_messages",+ "tableTo": "sessions",+ "columnsFrom": [+ "recipient_session_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "bot_group_members": {+ "name": "bot_group_members",+ "columns": {+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "bot_id": {+ "name": "bot_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "last_seen_sequence": {+ "name": "last_seen_sequence",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "joined_at": {+ "name": "joined_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "idx_bot_group_members_bot": {+ "name": "idx_bot_group_members_bot",+ "columns": [+ "bot_id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "bot_group_members_group_id_bot_groups_id_fk": {+ "name": "bot_group_members_group_id_bot_groups_id_fk",+ "tableFrom": "bot_group_members",+ "tableTo": "bot_groups",+ "columnsFrom": [+ "group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "bot_group_members_bot_id_bot_profiles_id_fk": {+ "name": "bot_group_members_bot_id_bot_profiles_id_fk",+ "tableFrom": "bot_group_members",+ "tableTo": "bot_profiles",+ "columnsFrom": [+ "bot_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "bot_group_members_group_id_bot_id_pk": {+ "columns": [+ "group_id",+ "bot_id"+ ],+ "name": "bot_group_members_group_id_bot_id_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "bot_group_messages": {+ "name": "bot_group_messages",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "sequence": {+ "name": "sequence",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'message'"+ },+ "author_kind": {+ "name": "author_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "author_bot_id": {+ "name": "author_bot_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "author_name": {+ "name": "author_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "''"+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "''"+ },+ "mentions_json": {+ "name": "mentions_json",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'{\"all\":false,\"botIds\":[]}'"+ },+ "notice_code": {+ "name": "notice_code",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "plan_id": {+ "name": "plan_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "files_json": {+ "name": "files_json",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'[]'"+ },+ "attachments_json": {+ "name": "attachments_json",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'[]'"+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "uniq_bot_group_messages_group_sequence": {+ "name": "uniq_bot_group_messages_group_sequence",+ "columns": [+ "group_id",+ "sequence"+ ],+ "isUnique": true+ },+ "uniq_bot_group_messages_group_client": {+ "name": "uniq_bot_group_messages_group_client",+ "columns": [+ "group_id",+ "client_id"+ ],+ "isUnique": true,+ "where": "\"bot_group_messages\".\"client_id\" IS NOT NULL"+ }+ },+ "foreignKeys": {+ "bot_group_messages_group_id_bot_groups_id_fk": {+ "name": "bot_group_messages_group_id_bot_groups_id_fk",+ "tableFrom": "bot_group_messages",+ "tableTo": "bot_groups",+ "columnsFrom": [+ "group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "bot_group_plan_steps": {+ "name": "bot_group_plan_steps",+ "columns": {+ "plan_id": {+ "name": "plan_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "bot_id": {+ "name": "bot_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "bot_name": {+ "name": "bot_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "task": {+ "name": "task",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'pending'"+ },+ "result_message_id": {+ "name": "result_message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "started_at": {+ "name": "started_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "finished_at": {+ "name": "finished_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "bot_group_plan_steps_plan_id_bot_group_plans_id_fk": {+ "name": "bot_group_plan_steps_plan_id_bot_group_plans_id_fk",+ "tableFrom": "bot_group_plan_steps",+ "tableTo": "bot_group_plans",+ "columnsFrom": [+ "plan_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "bot_group_plan_steps_plan_id_position_pk": {+ "columns": [+ "plan_id",+ "position"+ ],+ "name": "bot_group_plan_steps_plan_id_position_pk"+ }+ },+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "bot_group_plans": {+ "name": "bot_group_plans",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "group_id": {+ "name": "group_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "request_text": {+ "name": "request_text",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "attachments_json": {+ "name": "attachments_json",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'[]'"+ },+ "organizer_bot_id": {+ "name": "organizer_bot_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "organizer_name": {+ "name": "organizer_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "current_step": {+ "name": "current_step",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "work_dir": {+ "name": "work_dir",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "branch": {+ "name": "branch",+ "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": {+ "idx_bot_group_plans_group_created": {+ "name": "idx_bot_group_plans_group_created",+ "columns": [+ "group_id",+ "created_at"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "bot_group_plans_group_id_bot_groups_id_fk": {+ "name": "bot_group_plans_group_id_bot_groups_id_fk",+ "tableFrom": "bot_group_plans",+ "tableTo": "bot_groups",+ "columnsFrom": [+ "group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "bot_groups": {+ "name": "bot_groups",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "reply_mode": {+ "name": "reply_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'all'"+ },+ "speaking_mode": {+ "name": "speaking_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'auto'"+ },+ "organizer_bot_id": {+ "name": "organizer_bot_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "project_dir": {+ "name": "project_dir",+ "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": {+ "idx_bot_groups_updated": {+ "name": "idx_bot_groups_updated",+ "columns": [+ "updated_at"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "bot_lifecycle_events": {+ "name": "bot_lifecycle_events",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "bot_id": {+ "name": "bot_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "event_type": {+ "name": "event_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "payload_json": {+ "name": "payload_json",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'{}'"+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "idx_bot_lifecycle_events_bot_created": {+ "name": "idx_bot_lifecycle_events_bot_created",+ "columns": [+ "bot_id",+ "created_at"+ ],+ "isUnique": false+ },+ "idx_bot_lifecycle_events_session_created": {+ "name": "idx_bot_lifecycle_events_session_created",+ "columns": [+ "session_id",+ "created_at"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "bot_lifecycle_events_bot_id_bot_profiles_id_fk": {+ "name": "bot_lifecycle_events_bot_id_bot_profiles_id_fk",+ "tableFrom": "bot_lifecycle_events",+ "tableTo": "bot_profiles",+ "columnsFrom": [+ "bot_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "bot_lifecycle_events_session_id_sessions_id_fk": {+ "name": "bot_lifecycle_events_session_id_sessions_id_fk",+ "tableFrom": "bot_lifecycle_events",+ "tableTo": "sessions",+ "columnsFrom": [+ "session_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "bot_profile_versions": {+ "name": "bot_profile_versions",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "bot_id": {+ "name": "bot_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "identity_source": {+ "name": "identity_source",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "''"+ },+ "capabilities_json": {+ "name": "capabilities_json",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'{}'"+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "uniq_bot_profile_versions_bot_version": {+ "name": "uniq_bot_profile_versions_bot_version",+ "columns": [+ "bot_id",+ "version"+ ],+ "isUnique": true+ },+ "idx_bot_profile_versions_bot_created": {+ "name": "idx_bot_profile_versions_bot_created",+ "columns": [+ "bot_id",+ "created_at"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "bot_profile_versions_bot_id_bot_profiles_id_fk": {+ "name": "bot_profile_versions_bot_id_bot_profiles_id_fk",+ "tableFrom": "bot_profile_versions",+ "tableTo": "bot_profiles",+ "columnsFrom": [+ "bot_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "bot_profiles": {+ "name": "bot_profiles",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "display_name": {+ "name": "display_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "''"+ },+ "avatar": {+ "name": "avatar",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'🤖'"+ },+ "avatar_color": {+ "name": "avatar_color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'violet'"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'active'"+ },+ "hidden_at": {+ "name": "hidden_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "pinned_at": {+ "name": "pinned_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "attention_reason": {+ "name": "attention_reason",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "attention_at": {+ "name": "attention_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "current_version": {+ "name": "current_version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 1+ },+ "canonical_session_id": {+ "name": "canonical_session_id",+ "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": {+ "idx_bot_profiles_status_updated": {+ "name": "idx_bot_profiles_status_updated",+ "columns": [+ "status",+ "updated_at"+ ],+ "isUnique": false+ },+ "idx_bot_profiles_canonical_session": {+ "name": "idx_bot_profiles_canonical_session",+ "columns": [+ "canonical_session_id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "bot_profiles_canonical_session_id_sessions_id_fk": {+ "name": "bot_profiles_canonical_session_id_sessions_id_fk",+ "tableFrom": "bot_profiles",+ "tableTo": "sessions",+ "columnsFrom": [+ "canonical_session_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "bot_runtime_snapshots": {+ "name": "bot_runtime_snapshots",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "bot_id": {+ "name": "bot_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "profile_version": {+ "name": "profile_version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "agent_kind": {+ "name": "agent_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "working_dir": {+ "name": "working_dir",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "memory_scope_key": {+ "name": "memory_scope_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "configured_json": {+ "name": "configured_json",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'{}'"+ },+ "resolved_json": {+ "name": "resolved_json",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'{}'"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "prepared_at": {+ "name": "prepared_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "applied_at": {+ "name": "applied_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "failed_at": {+ "name": "failed_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "failure_json": {+ "name": "failure_json",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "idx_bot_runtime_snapshots_bot_prepared": {+ "name": "idx_bot_runtime_snapshots_bot_prepared",+ "columns": [+ "bot_id",+ "prepared_at"+ ],+ "isUnique": false+ },+ "idx_bot_runtime_snapshots_session_prepared": {+ "name": "idx_bot_runtime_snapshots_session_prepared",+ "columns": [+ "session_id",+ "prepared_at"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "bot_runtime_snapshots_bot_id_bot_profiles_id_fk": {+ "name": "bot_runtime_snapshots_bot_id_bot_profiles_id_fk",+ "tableFrom": "bot_runtime_snapshots",+ "tableTo": "bot_profiles",+ "columnsFrom": [+ "bot_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "bot_runtime_snapshots_session_id_sessions_id_fk": {+ "name": "bot_runtime_snapshots_session_id_sessions_id_fk",+ "tableFrom": "bot_runtime_snapshots",+ "tableTo": "sessions",+ "columnsFrom": [+ "session_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "bot_session_links": {+ "name": "bot_session_links",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "bot_id": {+ "name": "bot_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "profile_version": {+ "name": "profile_version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 1+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "route_key": {+ "name": "route_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "archived_at": {+ "name": "archived_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "uniq_bot_session_links_session": {+ "name": "uniq_bot_session_links_session",+ "columns": [+ "session_id"+ ],+ "isUnique": true+ },+ "uniq_bot_session_links_canonical_per_bot": {+ "name": "uniq_bot_session_links_canonical_per_bot",+ "columns": [+ "bot_id"+ ],+ "isUnique": true,+ "where": "\"bot_session_links\".\"role\" = 'canonical'"+ },+ "idx_bot_session_links_bot_role": {+ "name": "idx_bot_session_links_bot_role",+ "columns": [+ "bot_id",+ "role"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "bot_session_links_bot_id_bot_profiles_id_fk": {+ "name": "bot_session_links_bot_id_bot_profiles_id_fk",+ "tableFrom": "bot_session_links",+ "tableTo": "bot_profiles",+ "columnsFrom": [+ "bot_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "bot_session_links_session_id_sessions_id_fk": {+ "name": "bot_session_links_session_id_sessions_id_fk",+ "tableFrom": "bot_session_links",+ "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_session_usage": {+ "name": "daily_session_usage",+ "columns": {+ "day": {+ "name": "day",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "tokens": {+ "name": "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_session_usage_day_session_id_pk": {+ "columns": [+ "day",+ "session_id"+ ],+ "name": "daily_session_usage_day_session_id_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": {}+ },+ "im_notification_origins": {+ "name": "im_notification_origins",+ "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+ },+ "message_id": {+ "name": "message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "chat_id": {+ "name": "chat_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {+ "im_notification_origins_channel_bot_context_id_user_id_message_id_pk": {+ "columns": [+ "channel",+ "bot_context_id",+ "user_id",+ "message_id"+ ],+ "name": "im_notification_origins_channel_bot_context_id_user_id_message_id_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_remote_opens": {+ "name": "orca_remote_opens",+ "columns": {+ "remote_session_id": {+ "name": "remote_session_id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "device_id": {+ "name": "device_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "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+ },+ "execution_device_id": {+ "name": "execution_device_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "remote_session_id": {+ "name": "remote_session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "last_bridged_message_id": {+ "name": "last_bridged_message_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "remote_released_at": {+ "name": "remote_released_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "pending_remote_report": {+ "name": "pending_remote_report",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "remote_stop_confirmed_at": {+ "name": "remote_stop_confirmed_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_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": {}+ },+ "plugin_task_requests": {+ "name": "plugin_task_requests",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "plugin_id": {+ "name": "plugin_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "operation": {+ "name": "operation",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "target_id": {+ "name": "target_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "request_key": {+ "name": "request_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "fingerprint": {+ "name": "fingerprint",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "payload": {+ "name": "payload",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "revision": {+ "name": "revision",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "plugin_task_request_key": {+ "name": "plugin_task_request_key",+ "columns": [+ "plugin_id",+ "operation",+ "target_id",+ "request_key"+ ],+ "isUnique": true+ },+ "plugin_task_target": {+ "name": "plugin_task_target",+ "columns": [+ "target_id",+ "plugin_id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "plugin_usage_events": {+ "name": "plugin_usage_events",+ "columns": {+ "call_id": {+ "name": "call_id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "subject_id": {+ "name": "subject_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "history_generation": {+ "name": "history_generation",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "occurred_at": {+ "name": "occurred_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "tool_name": {+ "name": "tool_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "version": {+ "name": "version",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "release_id": {+ "name": "release_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "outcome": {+ "name": "outcome",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'unknown'"+ },+ "report_target": {+ "name": "report_target",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "report_state": {+ "name": "report_state",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'not-applicable'"+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "attempt_count": {+ "name": "attempt_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ }+ },+ "indexes": {+ "plugin_usage_events_time_idx": {+ "name": "plugin_usage_events_time_idx",+ "columns": [+ "subject_id",+ "occurred_at"+ ],+ "isUnique": false+ },+ "plugin_usage_events_task_idx": {+ "name": "plugin_usage_events_task_idx",+ "columns": [+ "subject_id",+ "session_id",+ "occurred_at"+ ],+ "isUnique": false+ },+ "plugin_usage_events_pending_idx": {+ "name": "plugin_usage_events_pending_idx",+ "columns": [+ "next_attempt_at",+ "occurred_at"+ ],+ "isUnique": false,+ "where": "\"plugin_usage_events\".\"report_state\" = 'pending'"+ }+ },+ "foreignKeys": {+ "plugin_usage_events_subject_id_plugin_usage_subjects_id_fk": {+ "name": "plugin_usage_events_subject_id_plugin_usage_subjects_id_fk",+ "tableFrom": "plugin_usage_events",+ "tableTo": "plugin_usage_subjects",+ "columnsFrom": [+ "subject_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "plugin_usage_subjects": {+ "name": "plugin_usage_subjects",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "stable_key": {+ "name": "stable_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "source_kind": {+ "name": "source_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "plugin_id": {+ "name": "plugin_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "organization_id": {+ "name": "organization_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "source_key": {+ "name": "source_key",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "server_root": {+ "name": "server_root",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "ghost_id": {+ "name": "ghost_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "display_name": {+ "name": "display_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "binding_revision": {+ "name": "binding_revision",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "recording_started_at": {+ "name": "recording_started_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "history_generation": {+ "name": "history_generation",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ }+ },+ "indexes": {+ "plugin_usage_subjects_source_idx": {+ "name": "plugin_usage_subjects_source_idx",+ "columns": [+ "stable_key"+ ],+ "isUnique": true+ },+ "plugin_usage_subjects_binding_idx": {+ "name": "plugin_usage_subjects_binding_idx",+ "columns": [+ "ghost_id",+ "binding_revision"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "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'"+ },+ "right_sidebar_tabs_bot_artifacts_singleton_idx": {+ "name": "right_sidebar_tabs_bot_artifacts_singleton_idx",+ "columns": [+ "session_id"+ ],+ "isUnique": true,+ "where": "\"right_sidebar_tabs\".\"kind\" = 'bot-artifacts'"+ }+ },+ "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_agent_kind": {+ "name": "model_agent_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "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+ },+ "agent_device_id": {+ "name": "agent_device_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": {}+ },+ "session_task_tags": {+ "name": "session_task_tags",+ "columns": {+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "tag_id": {+ "name": "tag_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "session_task_tags_tag_idx": {+ "name": "session_task_tags_tag_idx",+ "columns": [+ "tag_id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "session_task_tags_session_id_sessions_id_fk": {+ "name": "session_task_tags_session_id_sessions_id_fk",+ "tableFrom": "session_task_tags",+ "tableTo": "sessions",+ "columnsFrom": [+ "session_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "session_task_tags_tag_id_task_tags_id_fk": {+ "name": "session_task_tags_tag_id_task_tags_id_fk",+ "tableFrom": "session_task_tags",+ "tableTo": "task_tags",+ "columnsFrom": [+ "tag_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "session_task_tags_session_id_tag_id_pk": {+ "columns": [+ "session_id",+ "tag_id"+ ],+ "name": "session_task_tags_session_id_tag_id_pk"+ }+ },+ "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'"+ },+ "scheduled_model_baseline": {+ "name": "scheduled_model_baseline",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "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+ },+ "context_window_runtime": {+ "name": "context_window_runtime",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "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+ },+ "pinned_at": {+ "name": "pinned_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "hidden_at": {+ "name": "hidden_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+ },+ "last_activity_at": {+ "name": "last_activity_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+ },+ "im_default_route": {+ "name": "im_default_route",+ "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+ },+ "agent_device_id": {+ "name": "agent_device_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "orca_remote_lead": {+ "name": "orca_remote_lead",+ "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": {}+ },+ "shared_task_events": {+ "name": "shared_task_events",+ "columns": {+ "id": {+ "name": "id",+ "type": "integer",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": true+ },+ "shared_task_id": {+ "name": "shared_task_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "revision": {+ "name": "revision",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "terminal": {+ "name": "terminal",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "snapshot": {+ "name": "snapshot",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "recorded_at": {+ "name": "recorded_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "shared_task_events_revision_idx": {+ "name": "shared_task_events_revision_idx",+ "columns": [+ "shared_task_id",+ "kind",+ "revision"+ ],+ "isUnique": true+ },+ "shared_task_events_session_idx": {+ "name": "shared_task_events_session_idx",+ "columns": [+ "session_id",+ "id"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {+ "shared_task_events_session_id_sessions_id_fk": {+ "name": "shared_task_events_session_id_sessions_id_fk",+ "tableFrom": "shared_task_events",+ "tableTo": "sessions",+ "columnsFrom": [+ "session_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "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_skill_recent": {+ "name": "idx_skill_usage_exposures_skill_recent",+ "columns": [+ "skill_name",+ "analyzer_version",+ "seen_at"+ ],+ "isUnique": false+ },+ "idx_skill_usage_exposures_skill_recent_any_version": {+ "name": "idx_skill_usage_exposures_skill_recent_any_version",+ "columns": [+ "skill_name",+ "seen_at"+ ],+ "isUnique": false+ },+ "idx_skill_usage_exposures_analyzer_recent_source": {+ "name": "idx_skill_usage_exposures_analyzer_recent_source",+ "columns": [+ "analyzer_version",+ "seen_at",+ "raw_file_path"+ ],+ "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": {}+ },+ "task_tags": {+ "name": "task_tags",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "name_customized": {+ "name": "name_customized",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "favorite_order": {+ "name": "favorite_order",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "sort_order": {+ "name": "sort_order",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "revision": {+ "name": "revision",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 1+ }+ },+ "indexes": {+ "task_tags_name_idx": {+ "name": "task_tags_name_idx",+ "columns": [+ "name"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {},+ "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 filediff --git a/apps/desktop/drizzle/meta/_journal.json b/apps/desktop/drizzle/meta/_journal.jsonindex 5ea53de741..c537edf0cb 100644--- a/apps/desktop/drizzle/meta/_journal.json+++ b/apps/desktop/drizzle/meta/_journal.json@@ -918,6 +918,13 @@"when": 1792662845114,"tag": "0130_parallel_devos","breakpoints": true+ },+ {+ "idx": 131,+ "version": "6",+ "when": 1792840624494,+ "tag": "0131_amused_puff_adder",+ "breakpoints": true}]}\ No newline at end of filediff --git a/apps/desktop/src/main/__tests__/touchUserSendBroadcast.test.ts b/apps/desktop/src/main/__tests__/touchUserSendBroadcast.test.tsindex 45e03832c1..1ba05e372d 100644--- a/apps/desktop/src/main/__tests__/touchUserSendBroadcast.test.ts+++ b/apps/desktop/src/main/__tests__/touchUserSendBroadcast.test.ts@@ -19,7 +19,7 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';const h = vi.hoisted(() => {const updateSetCalls: Array<Record<string, unknown>> = [];- // 验证 SELECT 结果队列。若队列为空,makeUpdateChain.set 会自动把"UPDATE 成功"行+ // 验证读回结果队列。若队列为空,makeUpdateChain.set 会自动把"UPDATE 成功"行// 填进来(userSendAt/updatedAt = 本次 ts),模拟正常路径。// 需要非默认结果(no-op/MAX updatedAt)的测试先 push 目标行再调函数。const selectResults: Array<Array<Record<string, unknown>>> = [];@@ -35,7 +35,7 @@ const h = vi.hoisted(() => {// 自动填充"UPDATE 落地"场景(验证 SELECT 返回该行,广播触发)。// 若测试预先 push 了结果,队列非空,跳过自动填充,使用预设值。if (selectResults.length === 0 && typeof payload.userSendAt === 'number') {- selectResults.push([{ userSendAt: payload.userSendAt, updatedAt: payload.userSendAt }]);+ selectResults.push([{ userSendAt: payload.userSendAt, lastActivityAt: payload.userSendAt, updatedAt: payload.userSendAt }]);}return chain;};@@ -44,6 +44,7 @@ const h = vi.hoisted(() => {const committed = error === undefined ? Promise.resolve(undefined) : Promise.reject(error);return Object.assign(committed, {returning: () => committed.then(() => {+ if (typeof update.userSendAt === 'number') return selectResults.shift() ?? [];if (!route.row) return [];Object.assign(route.row, update);return [{ ...route.row }];@@ -315,6 +316,7 @@ describe('touchUserSendInDb 广播 sessions:patched(device-link 项目归属收h.selectResults.push([{userSendAt: atMs,+ lastActivityAt: atMs,updatedAt: atMs,source,workingDir,@@ -345,6 +347,7 @@ describe('touchUserSendInDb 广播 sessions:patched(device-link 项目归属收h.selectResults.push([{userSendAt: atMs,+ lastActivityAt: atMs,updatedAt: atMs,workingDir: '/repo',...fields,@@ -360,6 +363,7 @@ describe('touchUserSendInDb 广播 sessions:patched(device-link 项目归属收h.selectResults.push([{userSendAt: atMs,+ lastActivityAt: atMs,updatedAt: atMs,workingDir: '/repo',source: 'desktop',@@ -394,12 +398,12 @@ describe('touchUserSendInDb 广播 sessions:patched(device-link 项目归属收// 本机所有窗口都收到(被控端自己的 renderer 据此把会话重归项目下)。expect(h.webContentsSend).toHaveBeenCalledWith('local-db:sessions:patched', {sessionId: 'sess-1',- patch: { userSendAt: iso, updatedAt: iso },+ patch: { userSendAt: iso, lastActivityAt: iso, updatedAt: iso },});// device-link tap:经 topic 路由把权威 userSendAt 推给订阅 sessions 的控制端。expect(h.tapWindowBroadcast).toHaveBeenCalledWith('local-db:sessions:patched', {sessionId: 'sess-1',- patch: { userSendAt: iso, updatedAt: iso },+ patch: { userSendAt: iso, lastActivityAt: iso, updatedAt: iso },});});@@ -420,9 +424,9 @@ describe('touchUserSendInDb 广播 sessions:patched(device-link 项目归属收expect(typeof payload.patch.updatedAt).toBe('string'); // ISO});- it('atomic guard: UPDATE no-op 时(验证 SELECT 返回空)跳过广播,不向 renderer 发送过时值', async () => {+ it('atomic guard: UPDATE no-op 时(RETURNING 返回空)跳过广播,不向 renderer 发送过时值', async () => {const atMs = 1_700_000_000_000;- // 预设空结果:WHERE 条件为假,UPDATE 为 no-op,SELECT 找不到行。+ // 预设空结果:WHERE 条件为假,UPDATE 为 no-op,RETURNING 没有行。h.selectResults.push([]);await touchUserSendInDb('sess-noop', atMs);@@ -432,17 +436,18 @@ describe('touchUserSendInDb 广播 sessions:patched(device-link 项目归属收expect(h.upsertRecentWorkdir).not.toHaveBeenCalled();});- it('MAX updatedAt: 广播使用 SELECT 读回的实际 updatedAt,防止 finishedAt 被 firedAt 回退', async () => {+ it('MAX updatedAt: 广播使用 RETURNING 读回的实际 updatedAt,防止 finishedAt 被 firedAt 回退', async () => {const firedAt = 1_700_000_000_000;const finishedAt = firedAt + 5_000; // run 完成路径已将 updatedAt 推进到 finishedAt- // 模拟 MAX(updated_at, firedAt) = finishedAt 的 SELECT 结果。- h.selectResults.push([{ userSendAt: firedAt, updatedAt: finishedAt }]);+ // 模拟 MAX(updated_at, firedAt) = finishedAt 的 RETURNING 结果。+ h.selectResults.push([{ userSendAt: firedAt, lastActivityAt: firedAt, updatedAt: finishedAt }]);await touchUserSendInDb('sess-max', firedAt);expect(h.tapWindowBroadcast).toHaveBeenCalledWith('local-db:sessions:patched', {sessionId: 'sess-max',patch: {userSendAt: new Date(firedAt).toISOString(),+ lastActivityAt: new Date(firedAt).toISOString(),updatedAt: new Date(finishedAt).toISOString(), // 广播 finishedAt,不回退到 firedAt},});diff --git a/apps/desktop/src/main/device-link/__tests__/mirrorCacheStore.test.ts b/apps/desktop/src/main/device-link/__tests__/mirrorCacheStore.test.tsindex ff6f62c0bf..ffa9d9a738 100644--- a/apps/desktop/src/main/device-link/__tests__/mirrorCacheStore.test.ts+++ b/apps/desktop/src/main/device-link/__tests__/mirrorCacheStore.test.ts@@ -753,6 +753,7 @@ describe('session list', () => {status: 'active',title: 'T',createdAt: '2026-01-01T00:00:00.000Z',+ lastActivityAt: '2026-01-02T00:00:00.000Z',deviceLinkConnectionStatus: 'connected',},],@@ -760,6 +761,7 @@ describe('session list', () => {]);const devices = await c.readSessionList();expect(devices).toHaveLength(1);+ expect(devices[0].sessions[0].lastActivityAt).toBe('2026-01-02T00:00:00.000Z');expect(devices[0].sessions[0]).not.toHaveProperty('deviceLinkConnectionStatus');});diff --git a/apps/desktop/src/main/device-link/mirrorCacheStore.ts b/apps/desktop/src/main/device-link/mirrorCacheStore.tsindex 829ae9b8c2..43d8ee7028 100644--- a/apps/desktop/src/main/device-link/mirrorCacheStore.ts+++ b/apps/desktop/src/main/device-link/mirrorCacheStore.ts@@ -1,3 +1,4 @@+import { getSessionListActivityAt } from '@cindy/maker-shared/session-activity';/*** mirrorCacheStore —— 控制端「远程会话镜像」的本地冷缓存(落盘)。* ---------------------------------------------------------------------------@@ -249,6 +250,7 @@ const SESSION_FIELD_WHITELIST = ['pinnedAt','preview','userSendAt',+ 'lastActivityAt','createdAt','updatedAt',] as const;@@ -309,7 +311,7 @@ export function normalizeDeviceSessions(function lastActivityTime(session: Record<string, unknown> | undefined): number {if (!session) return 0;return (- parseTime(session.userSendAt) || parseTime(session.updatedAt) || parseTime(session.createdAt)+ parseTime(getSessionListActivityAt({ lastActivityAt: session.lastActivityAt, userSendAt: session.userSendAt, updatedAt: session.updatedAt })) || parseTime(session.createdAt));}diff --git a/apps/desktop/src/main/goal-host/__tests__/controller.test.ts b/apps/desktop/src/main/goal-host/__tests__/controller.test.tsindex 49eaae2eea..068d1d7f0b 100644--- a/apps/desktop/src/main/goal-host/__tests__/controller.test.ts+++ b/apps/desktop/src/main/goal-host/__tests__/controller.test.ts@@ -412,6 +412,7 @@ function makeController(depOverrides: Partial<GoalControllerDeps> = {}) {const persistedLimits: GoalLimits[] = [];const notices: Array<{ sessionId: string; kind: string }> = [];const userMessages: Array<{ sessionId: string; content: string; updated?: boolean }> = [];+ const stopped = vi.fn();// 可变:测试按需设置"账号是否受限 + resetAt"。let accountLimit: AccountLimitInfo | null = null;// 可变:模拟"会话已关闭 / 此刻 hydrate 不出来"(ensureSession 返回 undefined)。@@ -423,6 +424,7 @@ function makeController(depOverrides: Partial<GoalControllerDeps> = {}) {isSessionInTurn: () => false,stopActiveGoalTurn: () => {},emitStatus: (u) => updates.push(u),+ onGoalStopped: stopped,getDefaults: () => ({ ...DEFAULT_LIMITS }),persistGoalSettingsOverride: (l) => persistedLimits.push(l),logger: { info: () => {}, warn: () => {}, error: () => {} },@@ -450,6 +452,7 @@ function makeController(depOverrides: Partial<GoalControllerDeps> = {}) {persistedLimits,notices,userMessages,+ stopped,setAccountLimit: (v: AccountLimitInfo | null) => {accountLimit = v;},@@ -490,6 +493,17 @@ describe('GoalController', () => {h = makeController();});+ it('reports one handoff when a goal is cleared, not on its intermediate turns', async () => {+ await startGoal(h);+ h.session.emitGoalTurn({ toolUse: true, verdictJson: '```json\n{"goal_status":"continue","reason":"wip"}\n```' });+ await tick();+ expect(h.stopped).not.toHaveBeenCalled();+ await h.controller.clearGoal('s1');+ expect(h.stopped).toHaveBeenCalledExactlyOnceWith('s1', 1000);+ await h.controller.clearGoal('s1');+ expect(h.stopped).toHaveBeenCalledTimes(1);+ });+// ── setGoal / updateGoal ──it('blocks an unconfirmed dispatch without retrying duplicate Goal work', async () => {const local = makeController();@@ -2388,6 +2402,7 @@ describe('GoalController', () => {expect(h.completions[0].summary.reason).toBe('green');expect(h.updates.at(-1)).toEqual({ sessionId: 's1', goal: null });expect(h.session.sends).toHaveLength(1); // no continuation+ expect(h.stopped).toHaveBeenCalledExactlyOnceWith('s1', 1000);});it('pauseGoal pauses an active goal, preserves counters, and stops continuation', async () => {@@ -2403,6 +2418,7 @@ describe('GoalController', () => {h.session.emitGoalTurn({ toolUse: true, verdictJson: '```json\n{"goal_status":"continue","reason":"x"}\n```' });await tick();expect(h.session.sends.length).toBe(sendsAfterPause);+ expect(h.stopped).toHaveBeenCalledExactlyOnceWith('s1', 1000);});it('detaches goal continuation synchronously before pause persistence can block', async () => {diff --git a/apps/desktop/src/main/goal-host/controller.ts b/apps/desktop/src/main/goal-host/controller.tsindex fa14408018..b64a6a51ca 100644--- a/apps/desktop/src/main/goal-host/controller.ts+++ b/apps/desktop/src/main/goal-host/controller.ts@@ -842,7 +842,7 @@ export class GoalController {if (this.turns.get(sessionId) !== limitBoundary) return reconcileLifecycleChange();if (limited) {this.stopSession(sessionId);- this.emit(limited);+ this.emit(limited, current.status);}return limited;}@@ -982,7 +982,7 @@ export class GoalController {await this.resumeGoal(sessionId);return reconcileLifecycleChange();}- this.emit(next);+ this.emit(next, state.status);if (next.status === 'active' &&state.status === 'budgetLimited' &&@@ -1128,9 +1128,12 @@ export class GoalController {}await this.awaitPendingLifecycle(clearBoundary);if (this.turns.get(sessionId) !== clearBoundary) return;+ const previousGoal = await this.deps.storage.get(sessionId);+ if (this.turns.get(sessionId) !== clearBoundary) return;await this.trackPersistence(clearBoundary, this.deps.storage.clear(sessionId));if (this.turns.get(sessionId) !== clearBoundary) return;this.deps.emitStatus({ sessionId, goal: null });+ if (previousGoal) this.deps.onGoalStopped?.(sessionId, this.now());this.turns.delete(sessionId);}@@ -1187,7 +1190,7 @@ export class GoalController {}),);if (this.turns.get(sessionId) !== pauseBoundary) return;- if (updated) this.emit(updated);+ if (updated) this.emit(updated, state.status);}/**@@ -1756,9 +1759,12 @@ export class GoalController {return session ? session.isTurnRunning() : false;}- private emit(state: GoalState): void {+ private emit(state: GoalState, previousStatus?: GoalState['status']): void {if (this.disposed || this.disposing) return;this.deps.emitStatus({ sessionId: state.sessionId, goal: toPayload(state) });+ if (previousStatus === 'active' && state.status !== 'active') {+ this.deps.onGoalStopped?.(state.sessionId, state.updatedAt);+ }}/**@@ -1993,6 +1999,7 @@ export class GoalController {// null emit 属于同一顺序提交;后续新目标必须在它之后再 emit active,// 否则旧 completion 的迟到 null 会把新 chip 隐藏。this.deps.emitStatus({ sessionId, goal: null });+ this.deps.onGoalStopped?.(sessionId, this.now());})(),);if (isCurrentTurn()) this.stopSession(sessionId);@@ -2091,7 +2098,7 @@ export class GoalController {},);if (!isCurrentTurn()) return;- if (updated) this.emit(updated);+ if (updated) this.emit(updated, state.status);this.resetTurn(sessionId);@@ -2122,7 +2129,7 @@ export class GoalController {}),);if (!isCurrent()) return true;- if (blocked) this.emit(blocked);+ if (blocked) this.emit(blocked, 'active');} catch (persistError) {this.deps.logger.error('[goal] failed to persist dispatch failure', {sessionId,@@ -2420,7 +2427,7 @@ export class GoalController {);if (!isCurrentLifecycle()) return;this.stopSession(sessionId);- if (limited) this.emit(limited);+ if (limited) this.emit(limited, state.status);return;}const rejectionRetry = this.dispatchRejectionRetries.get(sessionId);diff --git a/apps/desktop/src/main/goal-host/index.ts b/apps/desktop/src/main/goal-host/index.tsindex 21137144f1..6185c0dda2 100644--- a/apps/desktop/src/main/goal-host/index.ts+++ b/apps/desktop/src/main/goal-host/index.ts@@ -23,7 +23,7 @@ import {import { isSessionSharedTaskActive } from '../device-link/sharedTaskDispatch.js';import { createMessage } from '../localDb/ipc/messages.js';import { readGoalSettings, writeGoalSettings } from '../maker-host/goal-settings-store.js';-import { getSessionRowSnapshot } from '../localDb/ipc/sessions.js';+import { getSessionRowSnapshot, touchSessionActivityInDb } from '../localDb/ipc/sessions.js';import {readAccountUsageLimit,sessionUsesOtherMachineAccount,@@ -77,6 +77,7 @@ export function startGoalController(deps: StartGoalControllerDeps): GoalControllbeforeDispatchUserTurn: deps.beforeDispatchUserTurn,onUndispatchedUserTurn: deps.onUndispatchedUserTurn,emitStatus: deps.broadcastStatus,+ onGoalStopped: (sessionId, atMs) => { void touchSessionActivityInDb(sessionId, atMs); },// 护栏默认从 goal-settings-store 读(系统默认 + 用户 override,规则 20);新建 goal// 时直接采用最新默认值。getDefaults: () => readGoalSettings(),diff --git a/apps/desktop/src/main/goal-host/types.ts b/apps/desktop/src/main/goal-host/types.tsindex 706a9c4d50..96d2516147 100644--- a/apps/desktop/src/main/goal-host/types.ts+++ b/apps/desktop/src/main/goal-host/types.ts@@ -199,6 +199,7 @@ export interface GoalControllerDeps {onUndispatchedUserTurn?: (sessionId: string) => void;/** 状态变化广播到 renderer(→ GOAL_STATUS_CHANGED);goal=null 表示已清除。 */emitStatus(update: GoalStatusUpdate): void;+ onGoalStopped?: (sessionId: string, atMs: number) => void;/*** 读当前"系统默认 + 用户 override"合并后的护栏默认(来自 goal-settings-store)。* 新建 goal 时读取最新值(规则 20)。diff --git a/apps/desktop/src/main/localDb/__tests__/conversationSearch.test.ts b/apps/desktop/src/main/localDb/__tests__/conversationSearch.test.tsindex 6e5bfd054a..ef4492418a 100644--- a/apps/desktop/src/main/localDb/__tests__/conversationSearch.test.ts+++ b/apps/desktop/src/main/localDb/__tests__/conversationSearch.test.ts@@ -95,6 +95,7 @@ function createSearchDb(): Database.Database {summary TEXT,provider_id TEXT,user_send_at INTEGER,+ last_activity_at INTEGER,agent_kind TEXT NOT NULL DEFAULT 'cc',orca_role TEXT,parent_session_id TEXT,diff --git a/apps/desktop/src/main/localDb/__tests__/migrationReplay.test.ts b/apps/desktop/src/main/localDb/__tests__/migrationReplay.test.tsindex 85cc9aaca4..ac12b58d07 100644--- a/apps/desktop/src/main/localDb/__tests__/migrationReplay.test.ts+++ b/apps/desktop/src/main/localDb/__tests__/migrationReplay.test.ts@@ -110,9 +110,12 @@ describeMigrationReplay('migration replay', () => {db.exec("CREATE TABLE migration_meta (key TEXT PRIMARY KEY, value TEXT NOT NULL); CREATE TABLE migration_history (seq INTEGER PRIMARY KEY, file_name TEXT NOT NULL, content_hash TEXT NOT NULL, applied_at INTEGER NOT NULL); CREATE TABLE sessions (id TEXT PRIMARY KEY)");if (shape !== 'missing') db.exec(`CREATE TABLE orca_workers (id TEXT PRIMARY KEY${shape === 'partial' ? ', pending_remote_report TEXT' : ''}); INSERT INTO orca_workers (id) VALUES ('worker-1');`);db.exec("CREATE TABLE bot_delegations (id TEXT PRIMARY KEY)");+ db.exec("INSERT INTO sessions (id) VALUES ('legacy-session')");const result = runMigrationReplay(db, { drizzleDir: drizzleDir(), currentVersion: 124 });- expect(result.applied.map((migration) => migration.seq)).toEqual([125, 126, 127, 128, 129, 130]);+ expect(result.applied.map((migration) => migration.seq)).toEqual([125, 126, 127, 128, 129, 130, 131]);expect(columnNames(db, 'sessions')).toContain('scheduled_model_baseline');+ expect(columnNames(db, 'sessions')).toContain('last_activity_at');+ expect(db.prepare('SELECT last_activity_at FROM sessions').get()).toEqual({ last_activity_at: null });expect(tableExists(db, 'plugin_usage_subjects')).toBe(true);expect(tableExists(db, 'plugin_usage_events')).toBe(true);expect(db.prepare("SELECT name FROM sqlite_master WHERE type='index' AND name='plugin_usage_events_pending_idx'").get()).toEqual({ name: 'plugin_usage_events_pending_idx' });diff --git a/apps/desktop/src/main/localDb/__tests__/orcaTeamStore.test.ts b/apps/desktop/src/main/localDb/__tests__/orcaTeamStore.test.tsindex b6690bea66..22ff2f2d38 100644--- a/apps/desktop/src/main/localDb/__tests__/orcaTeamStore.test.ts+++ b/apps/desktop/src/main/localDb/__tests__/orcaTeamStore.test.ts@@ -603,6 +603,7 @@ describe('orcaTeamStore', () => {hidden_at INTEGER,summary TEXT,user_send_at INTEGER,+ last_activity_at INTEGER,agent_kind TEXT NOT NULL DEFAULT 'codex',orca_role TEXT,parent_session_id TEXT,diff --git a/apps/desktop/src/main/localDb/__tests__/sessionListPagination.test.ts b/apps/desktop/src/main/localDb/__tests__/sessionListPagination.test.tsindex 73009757be..e8a01a0fe2 100644--- a/apps/desktop/src/main/localDb/__tests__/sessionListPagination.test.ts+++ b/apps/desktop/src/main/localDb/__tests__/sessionListPagination.test.ts@@ -25,6 +25,9 @@ it('pages the actual list query across tied timestamps without skipping or repeainsert.run(`s${String(n).padStart(4, '0')}`, 'archived', Math.floor(n / 3), 'cached preview');insert.run('active', 'active', 200, 'active');insert.run('deleted', 'deleted', 200, 'deleted');+ sqlite.prepare('UPDATE sessions SET last_activity_at=? WHERE id=?').run(900, 's0506');+ const first = await selectSessionListRows(db, eq(sessions.status, 'archived'), 1);+ expect(first[0].session.lastActivityAt).toBe(900);const ids: string[] = [];let before: { id: string; updatedAt: number } | undefined;for (;;) {diff --git a/apps/desktop/src/main/localDb/client/__tests__/drizzleProxy.test.ts b/apps/desktop/src/main/localDb/client/__tests__/drizzleProxy.test.tsindex 01ef34c621..d13db09738 100644--- a/apps/desktop/src/main/localDb/client/__tests__/drizzleProxy.test.ts+++ b/apps/desktop/src/main/localDb/client/__tests__/drizzleProxy.test.ts@@ -40,6 +40,7 @@ const DRIZZLE_PROXY_SCHEMA = [pinned_at INTEGER,hidden_at INTEGER,user_send_at INTEGER,+ last_activity_at INTEGER,agent_kind TEXT NOT NULL DEFAULT 'cc',orca_role TEXT,parent_session_id TEXT,diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.tsindex 8702345b33..f541b53e9d 100644--- a/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts+++ b/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts@@ -315,6 +315,7 @@ function createDb(filename = ':memory:'): void {summary TEXT,provider_id TEXT,user_send_at INTEGER,+ last_activity_at INTEGER,agent_kind TEXT NOT NULL DEFAULT 'cc',orca_role TEXT,parent_session_id TEXT,diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/sessionAutoTitlePersist.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/sessionAutoTitlePersist.test.tsindex eb3a3ef296..c1047f687b 100644--- a/apps/desktop/src/main/localDb/ipc/__tests__/sessionAutoTitlePersist.test.ts+++ b/apps/desktop/src/main/localDb/ipc/__tests__/sessionAutoTitlePersist.test.ts@@ -95,6 +95,7 @@ function createDb(initialTitle: string): void {updated_at INTEGER NOT NULL,agent_kind TEXT NOT NULL DEFAULT 'cc',user_send_at INTEGER,+ last_activity_at INTEGER,parent_session_id TEXT,forked_at_message_id TEXT,worktree_path TEXT,diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsHiddenTasks.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsHiddenTasks.test.tsindex 962854e0c2..5b474ca8de 100644--- a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsHiddenTasks.test.ts+++ b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsHiddenTasks.test.ts@@ -88,6 +88,7 @@ function createDb(): void {updated_at INTEGER NOT NULL,agent_kind TEXT NOT NULL DEFAULT 'cc',user_send_at INTEGER,+ last_activity_at INTEGER,parent_session_id TEXT,forked_at_message_id TEXT,worktree_path TEXT,diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsRestoreIfArchived.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsRestoreIfArchived.test.tsindex aac6e7536b..f430d34f49 100644--- a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsRestoreIfArchived.test.ts+++ b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsRestoreIfArchived.test.ts@@ -113,6 +113,7 @@ function createDb(): void {updated_at INTEGER NOT NULL,agent_kind TEXT NOT NULL DEFAULT 'cc',user_send_at INTEGER,+ last_activity_at INTEGER,parent_session_id TEXT,forked_at_message_id TEXT,worktree_path TEXT,diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.tsindex f1006aeb07..3d608985bf 100644--- a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts+++ b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts@@ -199,7 +199,9 @@ import {setSessionWorktreeRecycle,updateSessionInDb,touchUserSendInDb,+ touchSessionActivityInDb,} from '../sessions';+import { markSessionTurnEnded, drainSessionActiveTurnWrites, beginSessionTurnEndedSuppression } from '../../sessionActiveTurn';import {clearAllSessionAttention,getAttentionCount,@@ -256,6 +258,7 @@ function createDb(): void {updated_at INTEGER NOT NULL,agent_kind TEXT NOT NULL DEFAULT 'cc',user_send_at INTEGER,+ last_activity_at INTEGER,parent_session_id TEXT,forked_at_message_id TEXT,worktree_path TEXT,@@ -1064,6 +1067,53 @@ describe('local-db:sessions:update handler wiring', () => {);});+ it('persists handoffs monotonically without changing the last human send or metadata clock', async () => {+ const before = h.sqlite!.prepare('SELECT user_send_at, updated_at FROM sessions WHERE id = ?').get('codex-local');+ await touchSessionActivityInDb('codex-local', 1_786_500_050_000);+ await touchSessionActivityInDb('codex-local', 1_786_500_040_000);+ expect(h.sqlite!.prepare('SELECT user_send_at, updated_at FROM sessions WHERE id = ?').get('codex-local')).toEqual(before);+ expect(h.sqlite!.prepare('SELECT last_activity_at FROM sessions WHERE id = ?').get('codex-local'))+ .toEqual({ last_activity_at: 1_786_500_050_000 });+ expect(h.tapWindowBroadcast).toHaveBeenCalledWith('local-db:sessions:patched', expect.objectContaining({+ sessionId: 'codex-local', patch: { lastActivityAt: new Date(1_786_500_050_000).toISOString() },+ }));+ await invokeUpdate('codex-local', { title: 'Renamed', status: 'archived' });+ markSessionTurnEnded('codex-local');+ await drainSessionActiveTurnWrites('codex-local');+ const releaseSuppression = beginSessionTurnEndedSuppression();+ try {+ await touchSessionActivityInDb('codex-local', 1_786_500_070_000);+ } finally {+ releaseSuppression();+ }+ expect(h.sqlite!.prepare('SELECT last_activity_at FROM sessions WHERE id = ?').get('codex-local'))+ .toEqual({ last_activity_at: 1_786_500_050_000 });+ });++ it('writes human send and activity together without rewinding a newer handoff', async () => {+ await touchSessionActivityInDb('codex-local', 1_786_500_060_000);+ await touchUserSendInDb('codex-local', 1_786_500_050_000);+ expect(h.sqlite!.prepare('SELECT user_send_at, last_activity_at FROM sessions WHERE id = ?').get('codex-local'))+ .toEqual({ user_send_at: 1_786_500_050_000, last_activity_at: 1_786_500_060_000 });+ expect(h.tapWindowBroadcast).toHaveBeenLastCalledWith('local-db:sessions:patched', expect.objectContaining({+ patch: expect.objectContaining({ lastActivityAt: new Date(1_786_500_060_000).toISOString() }),+ }));+ h.tapWindowBroadcast.mockClear();+ await touchUserSendInDb('codex-local', 1_786_500_050_000);+ expect(h.tapWindowBroadcast).not.toHaveBeenCalled();+ });++ it('does not advance a terminal handoff while the goal is active', async () => {+ h.sqlite!.exec("CREATE TABLE session_goals (session_id TEXT PRIMARY KEY, status TEXT); INSERT INTO session_goals VALUES ('codex-local', 'active')");+ await touchSessionActivityInDb('codex-local', 1_786_500_050_000, true);+ expect(h.sqlite!.prepare('SELECT last_activity_at FROM sessions WHERE id = ?').get('codex-local'))+ .toEqual({ last_activity_at: null });+ h.sqlite!.prepare("UPDATE session_goals SET status = 'paused'").run();+ await touchSessionActivityInDb('codex-local', 1_786_500_060_000, true);+ expect(h.sqlite!.prepare('SELECT last_activity_at FROM sessions WHERE id = ?').get('codex-local'))+ .toEqual({ last_activity_at: 1_786_500_060_000 });+ });+it.each([['generic', 'archived'],['generic', 'deleted'],diff --git a/apps/desktop/src/main/localDb/ipc/sessions.ts b/apps/desktop/src/main/localDb/ipc/sessions.tsindex 80d0594fb9..f4f235bac0 100644--- a/apps/desktop/src/main/localDb/ipc/sessions.ts+++ b/apps/desktop/src/main/localDb/ipc/sessions.ts@@ -1,4 +1,5 @@import { removeSessionModelInterface } from '../../maker-host/session-model-interface.js';+import { isEndedWriteSuppressed } from '../sessionActiveTurn.js';import { ensureOpenedProjectGit, openSession } from '../sessionOpening.js';import {claimOwnedProvisionalSession,@@ -1139,8 +1140,37 @@ export async function getSessionFsSnapshot(id: string): Promise<{}}+export async function touchSessionActivityInDb(+ id: string,+ atMs = Date.now(),+ skipActiveGoal = false,+): Promise<void> {+ if (isEndedWriteSuppressed()) return;+ const ownerScope = captureOwnerScope();+ try {+ const db = getDbClient().drizzle;+ const updated = await db.update(sessions)+ .set({ lastActivityAt: sql`MAX(COALESCE(${sessions.lastActivityAt}, 0), ${atMs})` })+ .where(and(+ eq(sessions.id, id),+ sql`COALESCE(${sessions.lastActivityAt}, 0) < ${atMs}`,+ skipActiveGoal+ ? sql`NOT EXISTS (SELECT 1 FROM session_goals WHERE session_id = ${id} AND status = 'active')`+ : undefined,+ ))+ .returning({ lastActivityAt: sessions.lastActivityAt });+ if (updated[0]?.lastActivityAt != null && isOwnerScopeCurrent(ownerScope)) {+ broadcastSessionPatched(id, {+ lastActivityAt: new Date(updated[0].lastActivityAt).toISOString(),+ }, ownerScope);+ }+ } catch (error) {+ log.warn('Failed to persist session list activity', { sessionId: id, error: String(error) });+ }+}+/**- * 内部 API:标记用户显式发送时间。+ * 内部 API:标记用户显式发送时间,同时推进列表最近活动时间。** 过去这一步由 renderer 在 sendMessage 里直接调 IPC。队列 / 插话迁到 main 事务* 协调器后,renderer 只发 intent,真正“这条输入已进入事务”的时间必须跟 main@@ -1157,36 +1187,30 @@ export async function touchUserSendInDb(id: string, atMs?: number): Promise<void// 通过旧值检查后都执行 UPDATE,后写入的更早时间戳会覆盖已写入的更新值。// WHERE 条件由 SQLite 行锁原子执行,消除竞态窗口。// updatedAt 用 MAX 防止 run 完成路径写入 finishedAt 后被更早的 firedAt 回退。- // 同步 bump updatedAt:侧栏时间轴统一读 sessions.updatedAt("最近有动静的会话"),- // 用户按下发送就是最典型的"有动静"—— userSendAt 保持"用户发送时刻"专用语义,- // updatedAt 表示"任意路径下这个 session 最近一次被推进",两者语义正交但需同刷。- await db+ // 保留 updatedAt 的既有写入;列表活动时间与真人发送时间在同一条 UPDATE 中推进。+ const updated = await db.update(sessions)- .set({ userSendAt: ts, updatedAt: sql`MAX(${sessions.updatedAt}, ${ts})` })+ .set({+ userSendAt: ts,+ lastActivityAt: sql`MAX(COALESCE(${sessions.lastActivityAt}, 0), ${ts})`,+ updatedAt: sql`MAX(${sessions.updatedAt}, ${ts})`,+ }).where(and(eq(sessions.id, id),sql`(${sessions.userSendAt} IS NULL OR ${sessions.userSendAt} < ${ts})`,),- );- // 验证 UPDATE 是否落地,避免向 renderer 广播过时值。- // WHERE 条件为假时(并发写入已领先,或 userSendAt 已 >= ts)UPDATE 为 no-op;- // 此时 DB 里的 userSendAt ≠ ts,SELECT 返回空,正确跳过广播。- // 通过 SELECT 拿回实际落库的 updatedAt(已经是 MAX'd 结果)用于广播,- // 避免把旧 ts 当作 updatedAt 广播给 renderer。- const updated = await db- .select({+ )+ .returning({userSendAt: sessions.userSendAt,+ lastActivityAt: sessions.lastActivityAt,updatedAt: sessions.updatedAt,workingDir: sessions.workingDir,workspaceKind: sessions.workspaceKind,remoteHostId: sessions.remoteHostId,source: sessions.source,orcaRole: sessions.orcaRole,- })- .from(sessions)- .where(and(eq(sessions.id, id), eq(sessions.userSendAt, ts)))- .limit(1);+ });if (updated.length === 0) return;// 广播 sessions:patched,让 renderer 把刚发过消息的会话从「草稿(未分类)」即时重归到// 项目分组下(projectGrouping 的草稿兜底:userSendAt==null && messages==0 → unclassified)。@@ -1200,6 +1224,7 @@ export async function touchUserSendInDb(id: string, atMs?: number): Promise<voidid,{userSendAt: new Date(updated[0].userSendAt!).toISOString(),+ lastActivityAt: new Date(updated[0].lastActivityAt!).toISOString(),updatedAt: new Date(updated[0].updatedAt).toISOString(),},ownerScope,@@ -2110,9 +2135,7 @@ export function registerSessionIpc(// 业务函数 forkSessionAtMessage 仍在 apps/desktop/src/main/maker-orchestration/fork.ts, 内部 SDK 调用// 走 maker-core 的 Maker.forkSdkSession (Codex 自动抛 NotSupportedError)。- // 单字段 bump:把 user_send_at 设为 now。fire-and-forget,不返回 row。- // 故意与 sessions:update 解耦——update 会同步刷 updated_at(mapper.ts:165),- // 那是给"字段类改动"用的;touchUserSend 只标记"对话活跃",绝不污染 updated_at。+ // 用户发送同时推进 user_send_at、last_activity_at 和既有 updated_at,不返回 row。ipcMain.handle('local-db:sessions:touchUserSend',async (_e, id: unknown, atMs: unknown): Promise<void> => {diff --git a/apps/desktop/src/main/localDb/mapper.ts b/apps/desktop/src/main/localDb/mapper.tsindex 010c37a85e..10ddf0c54c 100644--- a/apps/desktop/src/main/localDb/mapper.ts+++ b/apps/desktop/src/main/localDb/mapper.ts@@ -267,6 +267,7 @@ export function sessionToCamel(row: SessionRowWithCount): Session {pinnedAt: msToIso(row.pinnedAt),hiddenAt: msToIso(row.hiddenAt),userSendAt: msToIso(row.userSendAt),+ lastActivityAt: msToIso(row.lastActivityAt),agentKind: row.agentKind as AgentKind,source: normalizeSessionSource(row.source),orcaRole: row.orcaRole as OrcaRole | null,diff --git a/apps/desktop/src/main/localDb/schema.ts b/apps/desktop/src/main/localDb/schema.tsindex c05b9dc770..c9ee3aa88e 100644--- a/apps/desktop/src/main/localDb/schema.ts+++ b/apps/desktop/src/main/localDb/schema.ts@@ -182,12 +182,10 @@ export const sessions = sqliteTable(providerId: text('provider_id'),/*** 用户最近一次"按下发送"的时刻(unix ms,NULL = 从未发过)。- * Sidebar Project / 组内 session 排序唯一时间轴:- * - 首条消息发出时由 renderer 通过 touchUserSend IPC 立刻 bump- * - NULL ⟺ 草稿,由 projectGrouping 直接归到未分类- * 不被 model/effort/title 改动等"字段类"修改触发——updatedAt 才是。+ * 保留真人发送语义及现有写入点;列表排序使用 lastActivityAt,旧数据回落到此列。*/userSendAt: integer('user_send_at'), // unix ms+ lastActivityAt: integer('last_activity_at'),/*** Agent 来源标识——session 级别。决定本 session 内 messages.agent_meta 的 JSON 形态。* 默认 'cc'(Claude Code)。未来扩展 'codex' 等时新建 session 即可,老 session 不动。diff --git a/apps/desktop/src/main/localDb/sessionActiveTurn.ts b/apps/desktop/src/main/localDb/sessionActiveTurn.tsindex 2577350a14..ad5b3f17ae 100644--- a/apps/desktop/src/main/localDb/sessionActiveTurn.ts+++ b/apps/desktop/src/main/localDb/sessionActiveTurn.ts@@ -103,7 +103,7 @@ export function beginSessionTurnEndedSuppression(): () => void {}/** ended 写抑制判定:quit freeze 或任一在持有的 owner 边界抑制。 */-function isEndedWriteSuppressed(): boolean {+export function isEndedWriteSuppressed(): boolean {return _quitFrozen || _endedWriteSuppressions > 0;}diff --git a/apps/desktop/src/main/maker-ipc/__tests__/orcaInterAgentDispatcher.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/orcaInterAgentDispatcher.test.tsindex efe15bf69c..9af0f9fee9 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/orcaInterAgentDispatcher.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/orcaInterAgentDispatcher.test.ts@@ -66,6 +66,7 @@ function createHarness(overrides: Partial<OrcaInterAgentDispatcherDeps<TestSessi});const deps: OrcaInterAgentDispatcherDeps<TestSessionMeta> = {createId: vi.fn(() => 'client-1'),+ onDirectInputDispatched: vi.fn(async () => {}),getSessionMeta: vi.fn(async () => meta),getSessionRowSnapshot: vi.fn(async () => dbRow),getLiveSession: vi.fn(() => liveSession),@@ -293,6 +294,7 @@ describe('Orca lead/worker dispatcher', () => {targetLastUserSendAt: '2026-06-12T01:02:03.000Z',});expect(h.order).toEqual(['send-called', 'db', 'change-set', 'accepted', 'vendor-released']);+ expect(h.deps.onDirectInputDispatched).toHaveBeenCalledExactlyOnceWith('target-session');expect(commit).toHaveBeenCalledTimes(1);expect(h.deps.beginDirectTurnChangeSet).toHaveBeenCalledWith('target-session', 'client-1');expect(h.deps.abortDirectTurnChangeSet).not.toHaveBeenCalled();diff --git a/apps/desktop/src/main/maker-ipc/__tests__/sendToSessionLazyResumePermission.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/sendToSessionLazyResumePermission.test.tsindex bf7ed20c08..61637a92b8 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/sendToSessionLazyResumePermission.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/sendToSessionLazyResumePermission.test.ts@@ -101,6 +101,7 @@ function botTaskDispatchSlice(): string {const lockReturn = 'return trackSendToSessionLockRun(targetSessionId, run, () => lockStage);';const sendToSessionInternal =slice('async function sendToSessionInternal(params: {', lockReturn) + `${lockReturn}\n}`;+ const sendWithBaseline = slice('async function sendUserMessageWithAwaitedGitBaseline(', '\n /**\n * 来源标签用的发送方身份快照');const dispatchBotSessionMessage = slice('const dispatchBotSessionMessage = async (params: {','\n setBotInvitationWelcomeDispatch(dispatchBotSessionMessage);',@@ -111,10 +112,11 @@ function botTaskDispatchSlice(): string {registerSource.indexOf('botDelegationServiceHolder = createBotDelegationService({'),);return ts.transpileModule(- `${sendToSessionInternal}+ `${sendWithBaseline}+${sendToSessionInternal}${dispatchBotSessionMessage}const delegationDispatch = ${delegationDispatch};-return { delegationDispatch, dispatchBotSessionMessage };`,+return { delegationDispatch, dispatchBotSessionMessage, sendToSessionInternal };`,{ compilerOptions: { target: ts.ScriptTarget.ES2022, module: ts.ModuleKind.None } },).outputText;}@@ -125,6 +127,7 @@ const loadBotTaskDispatch = new Function('scope',`with (scope) { return (function () { ${botTaskDispatchSlice()} })(); }`,) as (scope: object) => {+ sendToSessionInternal: (input: Record<string, unknown>) => Promise<{ ok: boolean; wakeKind?: string }>;dispatchBotSessionMessage: (input: Record<string, unknown>) => Promise<{ ok: boolean; wakeKind?: string }>;delegationDispatch: (input: Record<string, unknown>,@@ -145,6 +148,24 @@ function botTaskDispatchHarness(}]);const noop = () => undefined;const asyncNoop = async () => undefined;+ const activity = new Map<string, number>();+ const touchSessionActivityInDb = vi.fn(async (id: string) => { activity.set(id, Date.now()); });+ const sendFor = (session: { id: string }) => async (+ _message: unknown,+ opts: SendOptions & { onAccepted?: () => Promise<void>; onDispatching?: () => void },+ ) => {+ sendOptions.push(opts);+ await opts.onAccepted?.();+ try { opts.onDispatching?.(); } catch (error) {+ if (error instanceof TurnDispatchRejectedError) return { accepted: false, reason: 'provider-rejected-before-dispatch' };+ throw error;+ }+ sentTo.push({ sessionId: session.id, planMode: opts.planMode });+ return { accepted: true };+ };+ for (const [id, session] of Object.entries(live)) {+ if (!('send' in session)) Object.assign(session, { send: sendFor({ id }) });+ }const dbChain = {from: () => dbChain,innerJoin: () => dbChain,@@ -152,6 +173,21 @@ function botTaskDispatchHarness(limit: async () => [],};const stubs: Record<string, unknown> = {+ touchSessionActivityInDb,+ assertCindyMakeSessionAvailable: noop,+ readSessionSource: asyncNoop,+ prepareUpstreamMergeTurn: noop,+ isCindyMakeWorktreePath: () => false,+ app: { getPath: () => '/fixture' },+ agentHandoffPending: { peek: asyncNoop },+ shouldPrependMobileClientPromptNote: () => false,+ noteChannelTurnSource: () => noop,+ channelTurnSourceFor: noop,+ beginTurnChangeSetAtDispatch: asyncNoop,+ clearPendingTurnChangeSets: noop,+ gitSnapshotCoordinator: null,+ deferredProductTurnFailureGate: { clearSession: noop },+ withCindyMakeProjectUse: (_root: string, _workdir: string, dispatch: () => Promise<unknown>) => dispatch(),assertTaskActionCurrent, hasTaskActionAuthorization, TurnDispatchRejectedError,AUTO_REVIEW_SOURCE_CONTENT, AUTO_REVIEW_USER_INTENT, AUTO_REVIEW_DELEGATED_CONTINUATION,restoreAutoReviewUserIntent, readAutoReviewHistory, verifiedOwnerRequestText,@@ -213,24 +249,9 @@ function botTaskDispatchHarness(ensureRemoteReadyForSessionStart: asyncNoop,bootstrapSession: async (opts: Record<string, unknown>) => {bootstrapped.push(opts);- return { session: { id: opts.id, agentKind: opts.agentKind } };+ return { session: { id: opts.id, agentKind: opts.agentKind, send: sendFor({ id: opts.id as string }) } };},markOrcaRoleIfNeeded: asyncNoop,- sendUserMessageWithAwaitedGitBaseline: async (- session: { id: string },- _message: string,- _clientId: string,- opts: SendOptions & { onAccepted?: () => Promise<void>; onDispatching?: () => void },- ) => {- sendOptions.push(opts);- await opts.onAccepted?.();- try { opts.onDispatching?.(); } catch (error) {- if (error instanceof TurnDispatchRejectedError) return { accepted: false, reason: 'provider-rejected-before-dispatch' };- throw error;- }- sentTo.push({ sessionId: session.id, planMode: opts.planMode });- return { accepted: true };- },assertDesktopSendDispatched: noop,isSessionRunningError: () => false,GroupToolAuthorizationError: class extends Error {},@@ -246,9 +267,18 @@ function botTaskDispatchHarness(throw new ReferenceError(`unstubbed dependency of the production slice: ${String(key)}`);},});- return { ...loadBotTaskDispatch(scope), bootstrapped, sentTo, sendOptions, readAutoReviewHistory };+ return { ...loadBotTaskDispatch(scope), bootstrapped, sentTo, sendOptions, readAutoReviewHistory, activity, touchSessionActivityInDb };}+it('advances an accepted send_to_session with a dispatcher without touching human-send time', async () => {+ const row = { permissionMode: 'auto', planModeEnabled: false, userSendAt: 123 };+ const current = botTaskDispatchHarness({ child: row }, { child: { id: 'child', agentKind: 'codex' } });+ const result = await current.sendToSessionInternal({ targetSessionId: 'child', message: 'Take over this work', dispatcherSessionId: 'lead' });+ expect(result).toMatchObject({ ok: true });+ expect(current.activity.get('child')).toBeGreaterThan(123);+ expect(row.userSendAt).toBe(123);+});+// #6895 review: the cloud-room dispatcher bypassed the ordinary send transaction.// Execute that production closure with the real restore scope (unit behavior in// this existing guard fixture); assert the route used to send, not call strings.@@ -324,9 +354,10 @@ describe('companion internal delivery after automation', () => {let current = { ...saved, agentKind: 'codex' as 'codex' | 'pi', model: 'temporary-model' };let baseline: string | null = JSON.stringify({ ...saved, scopeId: 'automation' });const live: Record<string, object> = {};- const makeLive = () => ({ id: 'child', ...current, isTurnRunning: () => false, getStatus: () => 'active' });- if (path === 'live') live.child = makeLive();let dispatchedModel: string | undefined;+ const makeLive = () => ({ id: 'child', ...current, isTurnRunning: () => false, getStatus: () => 'active',+ send: async () => { dispatchedModel = current.model; return { accepted: true }; } });+ if (path === 'live') live.child = makeLive();const scope = createScheduledModelScope({createId: () => 'unused', read: async () => ({ profile: current, baseline }),write: async (_id, value) => { baseline = value ? JSON.stringify(value) : null; },@@ -336,8 +367,8 @@ describe('companion internal delivery after automation', () => {const h = botTaskDispatchHarness({ child: { permissionMode: 'auto', planModeEnabled: false } }, live, {scheduledModelScope: scope,maker: { getSession: (id: string) => live[id], getSessionMeta: async () => ({ id: 'child', ...current, workDir: '/tmp/fixture/child' }) },- bootstrapSession: async (opts: Record<string, unknown>) => ({ session: { id: 'child', model: opts.model } }),- sendUserMessageWithAwaitedGitBaseline: async (session: { model: string }) => { dispatchedModel = session.model; return { accepted: true }; },+ bootstrapSession: async (opts: Record<string, unknown>) => ({ session: { id: 'child', model: opts.model,+ send: async () => { dispatchedModel = String(opts.model); return { accepted: true }; } } }),});const result = await h.dispatchBotSessionMessage({ targetSessionId: 'child', message: 'Next owner message', clientId: 'cloud-room:next' });expect(result.ok).toBe(true);diff --git a/apps/desktop/src/main/maker-ipc/__tests__/sessionEventPipeline.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/sessionEventPipeline.test.tsindex fe16981efe..a19e7c572b 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/sessionEventPipeline.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/sessionEventPipeline.test.ts@@ -352,6 +352,7 @@ function harness() {deferredCodexRestartHolder: null,refreshRemoteCodexMcpOnTurnSettledHolder: null,markTurnEndedAfterPersistDrain: effects.fn('turn-drain'),+ noteSessionListActivity: effects.fn('list-activity'),contextOverflowRolloverHolder: null,lastReportedModelUsageBySession: new Map(),claudeOutputLagTimingGuard: new ClaudeOutputLagTimingGuard(),@@ -425,6 +426,38 @@ function ordered(...names: string[]) {}describe('production Session event pipeline', () => {+ it('ignores idle status without a turn and an interrupted turn reserved for automatic continuation', async () => {+ const current = harness();+ try {+ current.emit(event('status', { isRunning: false }));+ expect(current.deps.noteSessionListActivity).not.toHaveBeenCalled();+ current.emit(event('status', { isRunning: true }));+ current.deps.agentInputCoordinatorHolder.isAutoResumePending.mockReturnValue(true);+ current.emit(event('status', { isRunning: false }));+ current.emit(event('done'));+ await microtasks();+ expect(current.deps.noteSessionListActivity).not.toHaveBeenCalled();+ } finally { await current.dispose(); }+ });+ it.each(['done', 'error', 'status'] as const)('records the %s handoff but not intermediate goal turns or background work', async terminal => {+ const current = harness();+ try {+ current.emit(event('status', { isRunning: true }));+ expect(current.deps.noteSessionListActivity).not.toHaveBeenCalled();+ current.emit(event(terminal, terminal === 'status' ? { isRunning: false } : {}));+ await microtasks();+ expect(current.deps.noteSessionListActivity).toHaveBeenCalledWith('task');+ current.deps.noteSessionListActivity.mockClear();+ current.emit(event('status', { isRunning: true }, { turnOrigin: { kind: 'goal' } }));+ current.emit(event(terminal, terminal === 'status' ? { isRunning: false } : {}, { turnOrigin: { kind: 'goal' } }));+ await microtasks();+ expect(current.deps.noteSessionListActivity).not.toHaveBeenCalled();+ current.emit(event('compact_boundary'));+ current.emit(event(terminal, terminal === 'status' ? { isRunning: false } : {}, { turnScope: 'background' }));+ await microtasks();+ expect(current.deps.noteSessionListActivity).not.toHaveBeenCalled();+ } finally { await current.dispose(); }+ });// Regression: a delegated report used to leave only tool rows in the chat.// The real pipeline must persist and broadcast its reply, then settle normally.it('delivers coordination progress and final text through the ordinary message pipeline', async () => {diff --git a/apps/desktop/src/main/maker-ipc/orcaInterAgentDispatcher.ts b/apps/desktop/src/main/maker-ipc/orcaInterAgentDispatcher.tsindex 3e41269bb7..05a4cb6f37 100644--- a/apps/desktop/src/main/maker-ipc/orcaInterAgentDispatcher.ts+++ b/apps/desktop/src/main/maker-ipc/orcaInterAgentDispatcher.ts@@ -164,6 +164,7 @@ export interface OrcaInterAgentDispatcherLogger {/** Orca dispatcher 的 I/O 边界,register.ts 只负责注入 DB、Maker、queue 和 role 解析能力。 */export interface OrcaInterAgentDispatcherDeps<TSessionMeta> {+ onDirectInputDispatched?: (sessionId: string) => void | Promise<void>;readAutoReviewHistory?: (sessionId: string) => Promise<AutoReviewHistoryMessage[]>;createId: () => string;getSessionMeta: (sessionId: string) => Promise<TSessionMeta | null>;@@ -925,6 +926,7 @@ async function sendPersistedUserMessageToSession<TSessionMeta>(// Keep the handoff for retries until the target actually accepts it. It is// model-only context: dbContent and any requeued message stay unchanged.if (pendingHandoff && sendResult.accepted) deps.consumePendingHandoff?.(session.id);+ if (sendResult.accepted) await deps.onDirectInputDispatched?.(session.id);return sendResult;},{ source, context },diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.tsindex eb37f9a451..26e0f0f799 100644--- a/apps/desktop/src/main/maker-ipc/register.ts+++ b/apps/desktop/src/main/maker-ipc/register.ts@@ -515,6 +515,7 @@ import {applyAgentSwitchResumeFallbackAtomically,broadcastSessionPatched,setSessionStatusPatchedListener,+ touchSessionActivityInDb,captureSessionRecycleScope,clearSessionContextInDb,createSessionRemoteHostIdReader,@@ -6209,6 +6210,9 @@ const sessionEventDependencies: SessionEventDependencies = {get markTurnEndedAfterPersistDrain() {return markTurnEndedAfterPersistDrain;},+ noteSessionListActivity: (sessionId: string) => {+ void touchSessionActivityInDb(sessionId, Date.now(), true);+ },get contextOverflowRolloverHolder() {return contextOverflowRolloverHolder;},@@ -11712,6 +11716,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)if (pendingHandoff && sendResult.accepted) {agentHandoffPending.consume(session.id);}+ if (sendResult.accepted) await touchSessionActivityInDb(session.id);return sendResult;} catch (err) {if (turnChangeSetStarted) {@@ -14792,6 +14797,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)}const orcaInterAgentDispatcher: OrcaInterAgentDispatcher = createOrcaInterAgentDispatcher({+ onDirectInputDispatched: sessionId => touchSessionActivityInDb(sessionId),readAutoReviewHistory: sessionId => readAutoReviewHistory(sessionId),createId,getSessionMeta: (sessionId) => maker.getSessionMeta(sessionId).catch(() => null),@@ -19914,6 +19920,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)// 插话并入正在运行的 turn,不开启新 turn:排队时登记的「新 turn 接管」回调不再适用,// 只释放登记(不运行),否则会给已在跑的 worker 另建一份 running/auto-bridge 身份。onSteerAccepted: async (sessionId, item) => {+ if (!item.autoResume) await touchSessionActivityInDb(sessionId);void settleTaskActionInput(item).catch(() => undefined);await settleTodoDispatch(sessionId, item.clientId, true);orcaInterAgentDispatcher.discardQueuedOrcaInterAgentAcceptedCallback(item.clientId);@@ -19956,6 +19963,9 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)settleQueuedAttachmentPersistenceFailure(sessionId, item.clientId, opts.retainForRetry);},onDispatchedUserTurn: async (sessionId, item, preVendorDispatchAt): Promise<void> => {+ if (!item.autoResume) {+ await touchSessionActivityInDb(sessionId, preVendorDispatchAt);+ }void settleTaskActionInput(item).catch(() => undefined);// 供应商组换电脑后的续跑派发出去了:协同 Worker 暂存的那次终态不再回报(续跑那一轮结束时照常回报结果)。if (item.autoResume === true && item.autoResumeInfo?.reason === USAGE_LIMIT_RESET_AUTO_RESUME_REASON) {diff --git a/apps/desktop/src/main/maker-ipc/sessionEventDelivery.ts b/apps/desktop/src/main/maker-ipc/sessionEventDelivery.tsindex f16bbb9b2a..8bc59dedb5 100644--- a/apps/desktop/src/main/maker-ipc/sessionEventDelivery.ts+++ b/apps/desktop/src/main/maker-ipc/sessionEventDelivery.ts@@ -20,6 +20,7 @@ import type { PreparedSessionEvent } from './sessionEventPreparation.js';import type { SessionStreamResult } from './sessionEventStream.js';import { isSessionErrorSuppressed } from './sessionErrorSuppression.js';export interface DeliverSessionEventDeps {+ readonly noteSessionListActivity: (sessionId: string) => void;readonly attemptBotCompactRuntimeRefresh: (session: Session, reason: string) => void;readonly orcaTeamServiceForEvents: Pick<OrcaTeamService, 'captureWorkerTerminalTurn'> | null;readonly agentInputCoordinatorHolder: Pick<@@ -46,7 +47,7 @@ export interface DeliverSessionEventDeps {) => void;readonly sessionTurnActivityTracker: Pick<SessionTurnActivityTracker,- 'scheduleIdleAfterTerminalBroadcast' | 'scheduleIdleAfterStatusBroadcast'+ 'isSessionInTurn' | 'scheduleIdleAfterTerminalBroadcast' | 'scheduleIdleAfterStatusBroadcast'>;readonly notifyGoalIdleAfterTurnSettled: (sessionId: string) => void;readonly settlePendingCredentialSwitch: (sessionId: string, source: string) => void;@@ -180,9 +181,17 @@ export function deliverSessionEvent(deps.agentInputCoordinatorHolder?.onExternalTurnSettled(session.id);deps.refreshRemoteCodexMcpOnTurnSettledHolder?.(session.id);} else if (shouldMarkTurnStatusIdleAfterBroadcast) {+ const wasInTurn = deps.sessionTurnActivityTracker.isSessionInTurn(session.id);deps.sessionTurnActivityTracker.scheduleIdleAfterStatusBroadcast(session.id);// status:isRunning=false 即逻辑 turn 结束(可重试 error 不发这个信号)。deps.markTurnEndedAfterPersistDrain(session.id);+ if (+ wasInTurn && event.turnOrigin?.kind !== 'goal' &&+ !deps.agentInputCoordinatorHolder?.isAutoResumePending(session.id) &&+ !deps.agentInputCoordinatorHolder?.isAutoResumeDeferred(session.id)+ ) {+ deps.noteSessionListActivity(session.id);+ }noteClaudeSessionTurnState(session.id, false);}if (event.type === 'done' && !isContinuationBoundary) {diff --git a/apps/desktop/src/main/maker-ipc/sessionEventTerminal.ts b/apps/desktop/src/main/maker-ipc/sessionEventTerminal.tsindex 9c774623e1..ff09037396 100644--- a/apps/desktop/src/main/maker-ipc/sessionEventTerminal.ts+++ b/apps/desktop/src/main/maker-ipc/sessionEventTerminal.ts@@ -60,6 +60,7 @@ import {type ProductTurnFailureOwner,} from './productTurnFailureOwner.js';export interface FinishSessionTerminalEventDeps {+ readonly noteSessionListActivity: (sessionId: string) => void;readonly onPluginTaskTerminal?: (sessionId: string, execution: { instanceId: string; generation: number }, outcome: 'completed' | 'failed' | 'cancelled' | 'interrupted', outputMessageId?: string) => void;readonly onSuccessfulProductTurn?: (sessionId: string,@@ -543,6 +544,14 @@ export function finishSessionTerminalEvent(}if (!isContinuationBoundary) {deps.markTurnEndedAfterPersistDrain(session.id);+ if (+ event.turnScope !== 'background' && event.turnOrigin?.kind !== 'goal' &&+ !autoResumeSuppressesPersist && !recoveryOwnsUnsuccessfulBoundary &&+ !deps.agentInputCoordinatorHolder?.isAutoResumePending(session.id) &&+ !deps.agentInputCoordinatorHolder?.isAutoResumeDeferred(session.id)+ ) {+ deps.noteSessionListActivity(session.id);+ }// 逻辑 turn 结束:跨段存活的计划行引用到此回收(continuation boundary// 上必须保留,否则最终 done 找不到计划行 → 无章无失败印记 → 胶囊永久// 钉住,review P1-1)。diff --git a/apps/desktop/src/main/scheduler-host/runner.ts b/apps/desktop/src/main/scheduler-host/runner.tsindex 3b2f10d021..6ff7604934 100644--- a/apps/desktop/src/main/scheduler-host/runner.ts+++ b/apps/desktop/src/main/scheduler-host/runner.ts@@ -2099,11 +2099,8 @@ export class MakerScheduleRunner implements ScheduleRunner {});throw new RoutineDispatchDeferredError('Routine revision changed before dispatch');}- // bump userSendAt:侧栏排序主键已切到 userSendAt ?? updatedAt,自动化任务- // fire 属"这个会话有了新一轮输入",与用户按下发送同权重,让 fire 出来的会话- // 即时冒到列表顶(否则已被用户发过消息、userSendAt 非空的绑定会话会被冻结在- // 旧时刻顶不上来)。fire-and-forget:失败只 warn,不阻塞本轮 run —— 它只是排序- // 元数据,落库失败最多让本次 fire 的会话晚一拍冒头,不影响 agent 执行。+ // 保留 scheduler 的既有 userSendAt 写入;该入口同时推进列表 lastActivityAt。+ // userSendAt 的历史口径清理另行处理,不改变活跃礼让判据。// 用 ctx.firedAt 对齐本轮 run.firedAt,顺延重试时也稳定。void touchUserSendInDb(session.id, ctx.firedAt).catch((err) => {this.deps.logger.warn?.('[runner] touchUserSend failed', {diff --git a/apps/desktop/src/renderer/__tests__/dateSessionGrouping.test.ts b/apps/desktop/src/renderer/__tests__/dateSessionGrouping.test.tsindex c5fac87297..3eaa8401b7 100644--- a/apps/desktop/src/renderer/__tests__/dateSessionGrouping.test.ts+++ b/apps/desktop/src/renderer/__tests__/dateSessionGrouping.test.ts@@ -30,6 +30,7 @@ function s(partial: Partial<Session>): Session {clearedAt: null,pinnedAt: partial.pinnedAt ?? null,userSendAt,+ lastActivityAt: partial.lastActivityAt,status: partial.status ?? 'active',agentKind: partial.agentKind ?? 'cc',parentSessionId: partial.parentSessionId ?? null,@@ -44,6 +45,16 @@ function s(partial: Partial<Session>): Session {}describe('groupSessionsByActivityDate', () => {+ it('mixes new handoff timestamps with legacy human-send and metadata fallbacks', () => {+ const groups = groupSessionsByActivityDate([+ s({ id: 'legacy', userSendAt: '2026-05-16T12:00:00', updatedAt: '2026-05-17T15:00:00' }),+ s({ id: 'handoff', lastActivityAt: '2026-05-17T10:00:00', userSendAt: '2026-05-01T00:00:00' }),+ s({ id: 'draft', userSendAt: null, updatedAt: '2026-05-17T09:00:00' }),+ ], new Date('2026-05-17T12:00:00'));+ expect(groups.map(group => group.sessions.map(session => session.id))).toEqual([+ ['handoff', 'draft'], ['legacy'],+ ]);+ });it('groups sessions into Today, Yesterday, concrete dates, and Older', () => {const now = new Date('2026-05-17T12:00:00');const groups = groupSessionsByActivityDate(diff --git a/apps/desktop/src/renderer/__tests__/remoteProjectsStore.test.ts b/apps/desktop/src/renderer/__tests__/remoteProjectsStore.test.tsindex 0db56888e1..26f2a9477a 100644--- a/apps/desktop/src/renderer/__tests__/remoteProjectsStore.test.ts+++ b/apps/desktop/src/renderer/__tests__/remoteProjectsStore.test.ts@@ -53,6 +53,18 @@ function mk(id: string, partial: Partial<Session> = {}): Session {}describe('remoteProjectsStore', () => {+ it('preserves an activity push while accepting an in-flight detail read', () => {+ const session = mk('handoff');+ remoteProjectsStore.setDeviceSessions('host', 'Host', [session]);+ const read = remoteProjectsStore.captureSessionRead('host', session.id);+ const lastActivityAt = '2026-01-02T00:00:00.000Z';+ remoteProjectsStore.applyPatch('host', session.id, { lastActivityAt });+ expect(read()).toBe(true);+ expect(read.mergeActivity(session)).toMatchObject({+ lastActivityAt,+ userSendAt: session.userSendAt,+ });+ });// Unit, #6529: ordinary lists deliberately omit side chats; a list refresh// must not erase detail loaded for an opened full-page follow-up.it('retains a hidden side chat across ordinary snapshots until an explicit deletion', () => {diff --git a/apps/desktop/src/renderer/__tests__/sidebarSessionTime.test.ts b/apps/desktop/src/renderer/__tests__/sidebarSessionTime.test.tsindex cc7b6e1428..4e4ecc59ed 100644--- a/apps/desktop/src/renderer/__tests__/sidebarSessionTime.test.ts+++ b/apps/desktop/src/renderer/__tests__/sidebarSessionTime.test.ts@@ -9,6 +9,7 @@ import { readFileSync } from 'node:fs';import { resolve } from 'node:path';import { describe, expect, it } from 'vitest';+import { getSessionListActivityAt } from '@cindy/maker-shared/session-activity';import {formatSidebarFutureTime,@@ -87,9 +88,12 @@ describe('formatSidebarFutureTime', () => {describe('SessionItem activity time', () => {it('always renders the right-side activity info from the sidebar sort clock', () => {expect(sessionItemSource).not.toContain('SHOW_SIDEBAR_TIMESTAMPS');- // activityIso uses max(userSendAt, updatedAt) to backfill pre-migration rowsexpect(sessionItemSource).toContain('const activityIso =');- expect(sessionItemSource).toContain('session.updatedAt');+ expect(formatSidebarTime(getSessionListActivityAt({+ lastActivityAt: '2026-05-20T11:15:00.000Z',+ userSendAt: '2026-05-19T12:00:00.000Z',+ updatedAt: '2026-05-20T12:00:00.000Z',+ }), t, new Date('2026-05-20T12:00:00.000Z'))).toBe('45 分钟');// C 期起时间渲染并入 SessionInfoMeta(任务信息复选,同一 activityIso 时间轴);// 时间文本与 text-sidebar-action-icon 色由该组件承担。// 2026-08-12 起多传 hasPrRef(让 PR 参与「按勾选顺序」排列),调用被 prettierdiff --git a/apps/desktop/src/renderer/features/cc-agent/lib/automationSidebarGrouping.ts b/apps/desktop/src/renderer/features/cc-agent/lib/automationSidebarGrouping.tsindex e6a7de2825..d4cb163cc7 100644--- a/apps/desktop/src/renderer/features/cc-agent/lib/automationSidebarGrouping.ts+++ b/apps/desktop/src/renderer/features/cc-agent/lib/automationSidebarGrouping.ts@@ -336,7 +336,7 @@ export function getVisibleAutomationGroupSessions(}/**- * 组内「最新一条」运行:按 sessionActivityMs(updatedAt / userSendAt 取较新)降序取首。+ * 组内「最新一条」运行:按 sessionActivityMs 的换手时间及旧数据回退降序取首。* 侧栏组头(折叠态)用它作为整组的代表 —— 状态、running/loading、点击打开目标都跟这条一致* (「组头 = 最新一条运行的代理」)。group.sessions 恒非空(分组至少 2 条),返回可能仍为* undefined 仅为类型安全兜底。diff --git a/apps/desktop/src/renderer/features/cc-agent/lib/dateSessionGrouping.ts b/apps/desktop/src/renderer/features/cc-agent/lib/dateSessionGrouping.tsindex 90d3deb4ac..077ca51794 100644--- a/apps/desktop/src/renderer/features/cc-agent/lib/dateSessionGrouping.ts+++ b/apps/desktop/src/renderer/features/cc-agent/lib/dateSessionGrouping.ts@@ -1,3 +1,4 @@+import { getSessionListActivityAt } from '@cindy/maker-shared/session-activity';import type { Session } from '@/lib/ccAgent.types';const DAY_MS = 24 * 60 * 60 * 1000;@@ -26,10 +27,8 @@ export function sessionCreatedMs(session: Session): number {}export function sessionActivityMs(session: Session): number {- // 以 userSendAt(用户最近一次按下发送)为主键排序:agent 回复 / /clear 等- // 只 bump updatedAt 的路径不再重排列表。userSendAt == null 时回落到 updatedAt,- // 兼容 touchUserSendInDb 失败的 scheduler fire 与从未发送过的草稿会话(历史存量)。- return session.userSendAt != null ? toMs(session.userSendAt) : toMs(session.updatedAt);+ // 日期分组与组内排序共用换手时钟,旧端或旧数据保留真人发送时间回退。+ return toMs(getSessionListActivityAt(session));}function startOfLocalDay(date: Date): Date {@@ -63,8 +62,7 @@ function classifyActivityDate(activity: Date, now: Date): Pick<DateSessionGroup,/*** Group sidebar sessions by recent local activity date.*- * Sessions are sorted by sessionActivityMs(userSendAt ?? updatedAt)——以用户最近- * 一次按下发送为主键,userSendAt 为空的会话(scheduler fire / 草稿)回落到 updatedAt。+ * Sessions are sorted by sessionActivityMs(lastActivityAt ?? userSendAt ?? updatedAt)。*/export function groupSessionsByActivityDate(sessions: readonly Session[],diff --git a/apps/desktop/src/renderer/features/cc-agent/lib/projectGrouping.ts b/apps/desktop/src/renderer/features/cc-agent/lib/projectGrouping.tsindex 8f911c96d2..c10c695fc8 100644--- a/apps/desktop/src/renderer/features/cc-agent/lib/projectGrouping.ts+++ b/apps/desktop/src/renderer/features/cc-agent/lib/projectGrouping.ts@@ -1,3 +1,4 @@+import { getSessionListActivityAt } from '@cindy/maker-shared/session-activity';/*** projectGrouping — CC Agent Sidebar 分组算法(纯函数)* ---------------------------------------------------------------------------@@ -10,10 +11,8 @@* 组内 sessions 先按 status (active 在 archived 之上) 再按 sortTime desc** 时间轴:- * - 排序唯一字段是 `sortTime = userSendAt ?? updatedAt`- * · userSendAt = "用户最近一次按下发送" 的瞬间,由 sendMessage 入口同步 bump,- * 不会被 model/effort/title 等字段类改动污染- * · 老数据 / 未发过消息的草稿 userSendAt 可能为 null —— 回落到 updatedAt 兜底+ * - 排序时间为 `lastActivityAt ?? userSendAt ?? updatedAt`,按接活与交还结果推进。+ * 老数据无活动时间时保留原有回退;字段修改和流式输出不推进新时钟。** 草稿识别(归未分类):* - workingDir 缺失 OR@@ -93,7 +92,7 @@ export interface ProjectNode {segments: number;/** 该 Project 下所有 session,已按 status 然后 sortTime desc 排序 */sessions: Session[];- /** 组内任意 session 的最大 sortTime(userSendAt ?? updatedAt),用于 Project 间排序 */+ /** 组内任意 session 的最大活动时间,用于 Project 间排序 */latestActivityAt: string;/** 来自本地持久项目目录;即使当前视图没有匹配会话也应保留项目节点。 */isPersistentLocal?: boolean;@@ -382,16 +381,12 @@ const toMs = (iso: string | null | undefined): number => {};/**- * 排序时间轴:以 userSendAt(用户最近一次按下发送)为主键。- * - userSendAt 存在时只认它 —— agent 回复 / /clear 等只 bump- * updatedAt 的路径不再重排列表,会话顺序稳定跟随"用户上次发送"。- * - userSendAt == null 时回落到 updatedAt:兼容 touchUserSendInDb 失败的 scheduler fire- * 与从未发送过的草稿会话,避免这类会话因取 0 沉到列表最底。+ * 排序与显示时间共用换手时钟;没有新字段的存量任务保留原有回退。*/const sortTimeMs = (s: Session): number =>- s.userSendAt != null ? toMs(s.userSendAt) : toMs(s.updatedAt);+ toMs(getSessionListActivityAt(s));-const sortTimeIso = (s: Session): string => s.userSendAt ?? s.updatedAt;+const sortTimeIso = (s: Session): string => getSessionListActivityAt(s);export const compareSessionsBySortTimeDesc = (a: Session, b: Session): number =>sortTimeMs(b) - sortTimeMs(a);@@ -451,7 +446,7 @@ export function pinnedSessionIdsInDisplayOrder(sessions: readonly Session[]): st* 排序合约:* - pinned 按 status → pinnedAt desc* - dialogues 按 status → sortTime desc- * - unclassified 按 status → sortTime desc (sortTime = userSendAt ?? updatedAt)+ * - unclassified 按 status → sortTime desc (sortTime = lastActivityAt ?? userSendAt ?? updatedAt)* - projects 按 latestActivityAt desc;组内 sessions 按 status → sortTime desc** 草稿判定:workingDir 缺失 ORdiff --git a/apps/desktop/src/renderer/features/cc-agent/lib/projectGroupsSelector.ts b/apps/desktop/src/renderer/features/cc-agent/lib/projectGroupsSelector.tsindex b3bbbe25b2..b87a250ab8 100644--- a/apps/desktop/src/renderer/features/cc-agent/lib/projectGroupsSelector.ts+++ b/apps/desktop/src/renderer/features/cc-agent/lib/projectGroupsSelector.ts@@ -1,3 +1,4 @@+import { getSessionListActivityAt } from '@cindy/maker-shared/session-activity';import type { Session } from '@/lib/ccAgent.types';import {groupSessions,@@ -22,7 +23,7 @@ const ROW_ONLY_FIELDS = new Set([]);function sameGroupingInput(a: Session, b: Session): boolean {- if ((a.userSendAt ?? a.updatedAt) !== (b.userSendAt ?? b.updatedAt)) return false;+ if (getSessionListActivityAt(a) !== getSessionListActivityAt(b)) return false;// Only crossing the draft boundary changes grouping.if (((a._count?.messages ?? 0) === 0) !== ((b._count?.messages ?? 0) === 0)) return false;const keys = new Set([...Object.keys(a), ...Object.keys(b)]);diff --git a/apps/desktop/src/renderer/features/cc-agent/lib/scheduledSessionGrouping.ts b/apps/desktop/src/renderer/features/cc-agent/lib/scheduledSessionGrouping.tsindex 42520a40d3..9f4daedb8c 100644--- a/apps/desktop/src/renderer/features/cc-agent/lib/scheduledSessionGrouping.ts+++ b/apps/desktop/src/renderer/features/cc-agent/lib/scheduledSessionGrouping.ts@@ -1,3 +1,4 @@+import { getSessionListActivityAt } from '@cindy/maker-shared/session-activity';/*** scheduledSessionGrouping — 自动化任务生成会话的来源识别* ---------------------------------------------------------------------------@@ -70,10 +71,9 @@ const toMs = (iso: string | null | undefined): number => {return Number.isFinite(t) ? t : 0;};-// 以 userSendAt(用户最近一次按下发送)为主键;null 时回落到 updatedAt,-// 兼容 touchUserSendInDb 失败的 scheduler fire 与从未发送过的会话(历史存量)。+// 自动化列表同样按换手时钟排序,旧数据保留既有回退。const sortTimeMs = (s: Session): number =>- s.userSendAt != null ? toMs(s.userSendAt) : toMs(s.updatedAt);+ toMs(getSessionListActivityAt(s));type TFunc = (key: string) => string;diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionItem.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionItem.tsxindex 3e80a4e5ae..94cc26d2d8 100644--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionItem.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionItem.tsx@@ -1,4 +1,5 @@import { SessionTaskMenu } from './SessionTaskMenu';+import { getSessionListActivityAt } from '@cindy/maker-shared/session-activity';import { TaskTagMenuSection, TaskTagEditor, TaskTagDots } from '@/features/task-tags/TaskTags';import { Button } from '@/components/ui/button';/**@@ -370,12 +371,8 @@ export const SessionItem = withSidebarNavigation<SessionItemProps>(function Sessconst canOpenTaskMenu = !navigationOnly || isSharedTaskPeer(session.deviceLinkDeviceId ?? '');const isPinned = session.pinnedAt != null;const isEmpty = isEmptyDraftSession(session);- // 取 userSendAt 与 updatedAt 中较新的值,兼容存量 DB 行(旧版只写 userSendAt),- // 与 projectGrouping/dateSessionGrouping 的排序时间轴保持一致。- const activityIso =- session.userSendAt && session.userSendAt > session.updatedAt- ? session.userSendAt- : session.updatedAt;+ // 显示时间与列表排序共用换手时钟,旧端与存量数据沿用回退。+ const activityIso = getSessionListActivityAt(session);// PR 信息(C' 期):勾选且有引用时取最新一条(prRefs 已按 lastSeenAt 降序)。const infoPrRef = taskInfoFields.includes('pr') ? prRefs[0] : undefined;const infoWorktree = useTaskInfoWorktree(session, taskInfoFields.includes('worktree'));@@ -1114,8 +1111,7 @@ export const SessionItem = withSidebarNavigation<SessionItemProps>(function Sess)}{/* 右侧任务信息 + Archive 快捷按钮。- 时间使用 sidebar 排序同一时间轴 session.updatedAt(scheduler 自动 fire- 也会 bump,不用 userSendAt 避免被绑定给定时任务的会话时间冻结)。+ 时间与 sidebar 排序共用 lastActivityAt 的回退口径。worktree 并入任务信息复选,与 PR / 费用同一槽,不再常驻分叉图标。archive 快捷按钮 hover/focus 时进同一格文档流,标题 truncate 让位;完整菜单仍走右键。槽宽跟可见内容走:平时信息槽有多宽占多宽,「任务信息 =diff --git a/apps/desktop/src/renderer/features/device-link/remoteProjectsStore.ts b/apps/desktop/src/renderer/features/device-link/remoteProjectsStore.tsindex 1f7f850084..175a23d236 100644--- a/apps/desktop/src/renderer/features/device-link/remoteProjectsStore.ts+++ b/apps/desktop/src/renderer/features/device-link/remoteProjectsStore.ts@@ -114,7 +114,7 @@ const detailPatchEpoch = new Map<string, number>();const sessionContentOrigins = new WeakMap<Session, Session>();// Activity and list presentation pushes do not establish a newer model route.const activityFields = ['totalMoney', 'totalCostUsd', 'totalTokenUsage', 'lastTurnEndedAt',- 'preview', 'title', 'userSendAt', 'updatedAt'] as const;+ 'preview', 'title', 'userSendAt', 'lastActivityAt', 'updatedAt'] as const;const activityFieldNames: ReadonlySet<string> = new Set(activityFields);type ActivityField = typeof activityFields[number];// Per-field markers distinguish pushes after a GET began, even equal-value pushes.diff --git a/apps/desktop/src/renderer/lib/__tests__/sessionBatchRead.test.ts b/apps/desktop/src/renderer/lib/__tests__/sessionBatchRead.test.tsindex 0036c56c9c..50e9a1d3b0 100644--- a/apps/desktop/src/renderer/lib/__tests__/sessionBatchRead.test.ts+++ b/apps/desktop/src/renderer/lib/__tests__/sessionBatchRead.test.ts@@ -73,4 +73,12 @@ describe('shared local and remote metadata reads', () => {expect((await readSessionBatch(['s']))[0].value?.status).toBe('archived');expect(getMany).toHaveBeenCalledTimes(2);});++ it.each([undefined, null, '2026-09-13T00:00:00Z'])('accepts the optional activity field from old and new hosts: %s', async lastActivityAt => {+ const session = { ...row('s'), lastActivityAt };+ invoke.mockResolvedValueOnce([session]);+ expect(await readSessionBatch(['s'], 'desktop')).toEqual([{ sessionId: 's', value: session }]);+ invoke.mockResolvedValueOnce([{ ...session, lastActivityAt: 123 }]);+ expect(await readSessionBatch(['s'], 'desktop')).toEqual([{ sessionId: 's' }]);+ });});diff --git a/apps/desktop/src/renderer/lib/ccAgent.types.ts b/apps/desktop/src/renderer/lib/ccAgent.types.tsindex 090f2d102c..a62d3cf3f4 100644--- a/apps/desktop/src/renderer/lib/ccAgent.types.ts+++ b/apps/desktop/src/renderer/lib/ccAgent.types.ts@@ -387,6 +387,7 @@ export interface Session {* 与 updatedAt 解耦——改 model/effort/title 等字段不会动它。*/userSendAt: string | null;+ lastActivityAt?: string | null;status: SessionStatus;/** 当前 session 接的 agent。老 session DEFAULT 'cc'。 */agentKind: AgentKind;diff --git a/apps/desktop/src/renderer/lib/sessionBatchRead.ts b/apps/desktop/src/renderer/lib/sessionBatchRead.tsindex ecb8a4e7fd..0d6fb76d24 100644--- a/apps/desktop/src/renderer/lib/sessionBatchRead.ts+++ b/apps/desktop/src/renderer/lib/sessionBatchRead.ts@@ -56,6 +56,7 @@ export function isSessionListRow(hasOptionalNullableString(session, 'clearedAt') &&hasOptionalNullableString(session, 'pinnedAt') &&hasOptionalNullableString(session, 'userSendAt') &&+ hasOptionalNullableString(session, 'lastActivityAt') &&hasOptionalNullableString(session, 'source') &&hasOptionalNullableString(session, 'orcaRole') &&hasOptionalNullableString(session, 'providerId') &&diff --git a/apps/mobile/src/session/mobileHomeListCache.ts b/apps/mobile/src/session/mobileHomeListCache.tsindex 6a363c95eb..f4454fb085 100644--- a/apps/mobile/src/session/mobileHomeListCache.ts+++ b/apps/mobile/src/session/mobileHomeListCache.ts@@ -1,3 +1,4 @@+import { getSessionListActivityAt } from '@cindy/maker-shared/session-activity';import { normalizeTaskTags } from '@cindy/maker-shared';import AsyncStorage from '@react-native-async-storage/async-storage';import type { RemoteSession } from '@/session/types';@@ -214,6 +215,7 @@ function coerceCachedSession(item: unknown): RemoteSession | null {status,agentKind: item.agentKind === 'codex' || item.agentKind === 'pi' ? item.agentKind : 'cc',userSendAt: typeof item.userSendAt === 'string' ? item.userSendAt : null,+ lastActivityAt: typeof item.lastActivityAt === 'string' ? item.lastActivityAt : null,createdAt,updatedAt: typeof item.updatedAt === 'string' ? item.updatedAt : createdAt,};@@ -243,7 +245,7 @@ function coerceCachedSession(item: unknown): RemoteSession | null {}function lastActivityTime(session: RemoteSession): string {- return session.userSendAt ?? session.updatedAt ?? session.createdAt;+ return getSessionListActivityAt(session) ?? session.createdAt;}function truncateText(value: string): string {diff --git a/apps/mobile/src/session/newSession.ts b/apps/mobile/src/session/newSession.tsindex 121c546b5a..88d669052e 100644--- a/apps/mobile/src/session/newSession.ts+++ b/apps/mobile/src/session/newSession.ts@@ -1,3 +1,4 @@+import { getSessionListActivityAt } from '@cindy/maker-shared/session-activity';import { modelNeedsReselection } from './modelReselection';import { stripTrailingPathSeparators } from '@cindy/maker-shared/path-text';import { collapseWorktreeDirForGrouping } from '@cindy/maker-shared/worktree-paths';@@ -384,7 +385,7 @@ export function buildRecentWorkspaceOptions(const members = membersByPath.get(pathKey) ?? [];members.push(session);membersByPath.set(pathKey, members);- const lastActivityAt = session.userSendAt ?? session.updatedAt ?? session.createdAt;+ const lastActivityAt = getSessionListActivityAt(session) ?? session.createdAt;const current = byPath.get(pathKey);if (!current) {byPath.set(pathKey, {diff --git a/apps/mobile/src/session/sessionRightStatus.ts b/apps/mobile/src/session/sessionRightStatus.tsindex 56803c1abf..9f7d2cfc19 100644--- a/apps/mobile/src/session/sessionRightStatus.ts+++ b/apps/mobile/src/session/sessionRightStatus.ts@@ -1,3 +1,4 @@+import { getSessionListActivityAt } from '@cindy/maker-shared/session-activity';/*** sessionRightStatus —— 会话行右侧状态槽的档位判定(纯函数,便于单测)。*@@ -30,8 +31,8 @@ export type MobileSessionRightStatus = SessionRightStatus;export function latestMobileSessionRow(item: SessionRow): SessionRow {return (item.automationGroup?.items.reduce((a, b) =>- Date.parse(b.session.userSendAt ?? b.session.updatedAt ?? b.session.createdAt) >- Date.parse(a.session.userSendAt ?? a.session.updatedAt ?? a.session.createdAt)+ Date.parse(getSessionListActivityAt(b.session) ?? b.session.createdAt) >+ Date.parse(getSessionListActivityAt(a.session) ?? a.session.createdAt)? b: a,) ?? itemdiff --git a/apps/mobile/src/session/types.ts b/apps/mobile/src/session/types.tsindex 0c104113bc..2a8409a85b 100644--- a/apps/mobile/src/session/types.ts+++ b/apps/mobile/src/session/types.ts@@ -97,6 +97,7 @@ export interface RemoteSession {forkedAtMessageId?: string | null;pinnedAt?: string | null;userSendAt: string | null;+ lastActivityAt?: string | null;createdAt: string;updatedAt: string;deviceLinkDeviceId?: string;diff --git a/docs/product-rules/sidebar-redesign-plan.md b/docs/product-rules/sidebar-redesign-plan.mdindex c39f3a6b09..466f93b344 100644--- a/docs/product-rules/sidebar-redesign-plan.md+++ b/docs/product-rules/sidebar-redesign-plan.md@@ -171,11 +171,15 @@ Cindy Make 分组固定在主列表顶部,不参与普通条目的优先级、| 选项 | 默认 | 行为 ||---|---|---|| 按优先级 | | 四档,对齐 Codex(2026-08-13 用户裁决「参考 Codex」):等你处理(等待回复 / 授权 / 出错)> 完成未读 > 运行中 > 其余;同档内按最近活动。正在看的任务钉住打开时的档位不跳位;只有从完成未读切走才排到已看过最前。已读已完成任务之间与按时间排序同口径,浏览不改序(2026-08-17 用户裁决) |-| 按最近活动 | **是** | 顶层条目按组内最新活动时间倒序(最近的在前);组内同。排序时钟 = `userSendAt ?? updatedAt`(以用户最近一次按下发送为主键,agent 回复只 bump `updatedAt` 不重排) |+| 按最近活动 | **是** | 顶层条目按组内最新活动时间倒序(最近的在前);组内同。排序与行右侧时间共用 `lastActivityAt ?? userSendAt ?? updatedAt`,按接活与交还结果的时刻更新;存量数据不回填 || 按创建时间 | | 按创建时间倒序,任务后续活动不改变顺序 |旧「手动排序」不再是任务排序的第三档。它排的是项目行,不是任务,和按时间/优先级互斥会让用户以为能拖单条任务。现拆成下一节的「项目排序」,可与任务排序叠加。存量 `sortBy=manual` 静默迁移为 `sortBy=recency` + `projectOrder=custom`。+最近活动遵循「换手才更新」:用户发送、继续或重试,其他任务/Orca/插件/定时任务交来输入并开始一轮,以及正常完成、终止型错误或逻辑轮次转为空闲时更新。目标模式的中间轮次不更新;整个目标完成、暂停、清除或停下待处理时更新一次。自动续跑开始、流式输出、工具调用、标题/模型/权限修改、归档/取消归档、进程关闭或回收、忽略中断、退出冻结与 compact 等内部动作不更新;可以识别为马上自动续跑的中断收尾也跳过。++这与主流产品按最新交接排列的方向一致:Codex 的 [recencyAt](https://github.com/openai/codex/pull/27910) 在新轮次开始时推进,独立于普通字段修改;其 Last updated 排序也关注回复完成。被其他线程调用却不上浮及防跳动快照造成顺序过时,分别见 [#36634](https://github.com/openai/codex/issues/36634) 与 [#36300](https://github.com/openai/codex/issues/36300)。微信、Slack、Telegram 的消息列表以最后一条消息为常见参照;这里采用交接边界,而不是流式片段逐条重排。本次不处理等待用户确认权限或回答问题,不清理定时任务既有 `userSendAt` 写入,也不改变 IM `/sessions` 和 Work Louder 的顺序。+### 3.2.1 项目排序 —— 仅「按项目分组」开启时出现| 选项 | 默认 | 行为 |diff --git a/packages/maker-shared/src/__tests__/sessionList.test.ts b/packages/maker-shared/src/__tests__/sessionList.test.tsindex 53a46bc333..b4ba98ca6a 100644--- a/packages/maker-shared/src/__tests__/sessionList.test.ts+++ b/packages/maker-shared/src/__tests__/sessionList.test.ts@@ -220,6 +220,19 @@ describe('sessionList', () => {});});+ it('uses handoff activity for remote ordering and row time without changing legacy fallbacks', () => {+ const now = Date.parse('2026-01-01T00:10:00.000Z');+ const sessions = [+ session('legacy', { userSendAt: '2026-01-01T00:04:00.000Z', updatedAt: '2026-01-01T00:09:00.000Z' }),+ session('handoff', { lastActivityAt: '2026-01-01T00:08:00.000Z', userSendAt: '2026-01-01T00:01:00.000Z' }),+ ];+ const sections = buildRemoteSessionSections(sessions, now);+ expect(sections.flatMap(section => section.data).map(item => item.session.id)).toEqual(['handoff', 'legacy']);+ expect(toRemoteSessionListItem(sessions[1], now)).toMatchObject({+ lastActivityAt: '2026-01-01T00:08:00.000Z', detail: expect.stringContaining('2 minutes ago'),+ });+ });+it('caps oversized message counts at 1000+', () => {const item = toRemoteSessionListItem(session('s-big', {title: '大库',diff --git a/packages/maker-shared/src/mobileHome.ts b/packages/maker-shared/src/mobileHome.tsindex 15d5c943e4..9546f84f00 100644--- a/packages/maker-shared/src/mobileHome.ts+++ b/packages/maker-shared/src/mobileHome.ts@@ -1,3 +1,4 @@+import { getSessionListActivityAt } from './sessionActivity.js';import {compareSessionListStrings,groupAutomationListItems,@@ -687,7 +688,7 @@ function projectTitle(workingDir: string): string {}function lastActivityTime(session: RemoteSessionListSessionLike): string {- return session.userSendAt ?? session.updatedAt ?? session.createdAt;+ return getSessionListActivityAt(session) ?? session.createdAt;}function mobileHomeEmptyState({diff --git a/packages/maker-shared/src/sessionActivity.ts b/packages/maker-shared/src/sessionActivity.tsindex 1cbae5ac4a..e6fdfed3dc 100644--- a/packages/maker-shared/src/sessionActivity.ts+++ b/packages/maker-shared/src/sessionActivity.ts@@ -1,5 +1,13 @@import type { WorkingPhase } from './workingStatus.js';+export function getSessionListActivityAt<Value>(session: {+ lastActivityAt?: Value | null;+ userSendAt?: Value | null;+ updatedAt: Value;+}): Value {+ return session.lastActivityAt ?? session.userSendAt ?? session.updatedAt;+}+/*** Canonical session control-plane status projection.*diff --git a/packages/maker-shared/src/sessionList.ts b/packages/maker-shared/src/sessionList.tsindex 387b2e2c3e..b54829b5b4 100644--- a/packages/maker-shared/src/sessionList.ts+++ b/packages/maker-shared/src/sessionList.ts@@ -2,7 +2,7 @@ import { messageContentToPreview } from './messageNormalize.js';import { stripTrailingPathSeparators } from './pathText.js';import { presentationDate, presentationText, type PresentationLocalizer } from './presentationLocalization.js';import { isSyntheticTriggerText } from './syntheticTrigger.js';-import { hasPendingSessionInterruption, type SessionInterruptionState } from './sessionActivity.js';+import { getSessionListActivityAt, hasPendingSessionInterruption, type SessionInterruptionState } from './sessionActivity.js';import type { RemoteSchedule, RemoteScheduleRun } from './scheduleTypes.js';import { toMillis, isUnreadScheduleRun, isUnreadFailedScheduleRun, activeScheduleFailures, classifyScheduleFailure, compareFailedScheduleRuns, type FailedScheduleRunSnapshot } from './scheduleModel.js';import { sessionCollaborationLabel, sessionWorktreeLabel } from './sessionIdentity.js';@@ -47,6 +47,7 @@ export interface RemoteSessionListSessionLike extends SessionInterruptionState {updatedAt: string;userId?: string;userSendAt?: string | null;+ lastActivityAt?: string | null;workspaceKind?: 'project' | 'dialogue' | string | null;workingDir: string | null;remoteHostId?: string | null;@@ -475,7 +476,7 @@ export function toRemoteSessionListItem(unnamedLabel?: string,localizer?: PresentationLocalizer,): RemoteSessionListItem {- const lastActivityAt = session.userSendAt ?? session.updatedAt ?? session.createdAt;+ const lastActivityAt = getSessionListActivityAt(session) ?? session.createdAt;const scheduleInfo = scheduleIndex?.get(session.id) ?? fallbackScheduleInfo(session);const worktreeLabel = sessionWorktreeLabel(session);return {@@ -819,7 +820,7 @@ function isDialogueSession(session: RemoteSession): boolean {}function lastActivity(session: RemoteSession): string {- return session.userSendAt ?? session.updatedAt ?? session.createdAt;+ return getSessionListActivityAt(session) ?? session.createdAt;}function projectTitle(workingDir: string): string {