Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
merge: integrate main and preserve scheduled model routes
Yuewei-LLd8dd390ceefb
diff --cc apps/desktop/drizzle/0131_schedule_model_location.sqlindex 0000000000,0000000000..027b7d63fdnew file mode 100644--- /dev/null+++ b/apps/desktop/drizzle/0131_schedule_model_location.sql@@@ -1,0 -1,0 +1,1 @@@++SELECT 1;diff --cc apps/desktop/drizzle/meta/0131_snapshot.jsonindex 0000000000,0000000000..14d03cebe2new file mode 100644--- /dev/null+++ b/apps/desktop/drizzle/meta/0131_snapshot.json@@@ -1,0 -1,0 +1,7222 @@@++{++ "version": "6",++ "dialect": "sqlite",++ "id": "529221ba-27ab-40b7-9f4d-c59e57abffdc",++ "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_agent_device_id": {++ "name": "model_agent_device_id",++ "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++ },++ "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++ }++ }++ }++ }++ }++}diff --cc apps/desktop/drizzle/meta/_journal.jsonindex 86cfa885b8,5ea53de741..f4fe7f4def--- a/apps/desktop/drizzle/meta/_journal.json+++ b/apps/desktop/drizzle/meta/_journal.json@@@ -915,9 -915,9 +915,16 @@@{"idx": 130,"version": "6",- "when": 1792659817002,- "tag": "0130_ambitious_hellfire_club",+ "when": 1792662845114,+ "tag": "0130_parallel_devos",+ "breakpoints": true++ },++ {++ "idx": 131,++ "version": "6",++ "when": 1792722442165,++ "tag": "0131_schedule_model_location",+ "breakpoints": true}]}diff --cc apps/desktop/drizzle/scripts/0131_schedule_model_location.tsindex e20c250639,0000000000..e20c250639mode 100644,000000..100644--- a/apps/desktop/drizzle/scripts/0131_schedule_model_location.ts+++ b/apps/desktop/drizzle/scripts/0131_schedule_model_location.tsdiff --cc apps/desktop/src/main/localDb/__tests__/migrationReplay.test.tsindex a7b3d6563e,85cc9aaca4..13b9e13fad--- a/apps/desktop/src/main/localDb/__tests__/migrationReplay.test.ts+++ b/apps/desktop/src/main/localDb/__tests__/migrationReplay.test.ts@@@ -111,7 -111,7 +111,7 @@@ describeMigrationReplay('migration replif (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)");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(tableExists(db, 'plugin_usage_subjects')).toBe(true);expect(tableExists(db, 'plugin_usage_events')).toBe(true);@@@ -216,35 -216,6 +216,35 @@@},);+ // Migration tier: upgrading an existing automation must preserve its content+ // and legacy inheritance; partial fixtures and an already-added column are safe.+ it.each(['missing table', 'legacy table', 'existing column'])(+ 'replays the scheduled Agent location migration with %s', (state) => {+ const { db, cleanup } = createTempDb();+ const stagedDir = mkdtempSync(path.join(tmpdir(), 'cindy-scheduled-agent-location-'));+ try {+ db.exec('CREATE TABLE migration_meta (key TEXT PRIMARY KEY NOT NULL, value TEXT NOT NULL)');- const migration = listMigrations(drizzleDir()).find((item) => item.seq === 130)!;++ const migration = listMigrations(drizzleDir()).find((item) => item.seq === 131)!;+ copyFileSync(migration.sqlPath, path.join(stagedDir, migration.fileName));+ mkdirSync(path.join(stagedDir, 'scripts'));+ copyFileSync(migration.tsScriptPath!, path.join(stagedDir, 'scripts', path.basename(migration.tsScriptPath!)));+ if (state !== 'missing table') {+ db.exec("CREATE TABLE schedules (id TEXT PRIMARY KEY, prompt TEXT); INSERT INTO schedules VALUES ('old', 'keep this prompt');");+ if (state === 'existing column') db.exec("ALTER TABLE schedules ADD model_agent_device_id TEXT; UPDATE schedules SET model_agent_device_id = 'shared:owner';");+ }+ for (let replay = 0; replay < 2; replay += 1) {+ runMigrationReplay(db, { drizzleDir: stagedDir, currentVersion: 129 });+ if (state === 'missing table') expect(tableExists(db, 'schedules')).toBe(false);+ else expect(db.prepare('SELECT * FROM schedules').all()).toEqual([{ id: 'old', prompt: 'keep this prompt',+ model_agent_device_id: state === 'existing column' ? 'shared:owner' : null }]);+ }+ } finally {+ rmSync(stagedDir, { recursive: true, force: true });+ cleanup();+ }+ },+ );+it('replays every drizzle migration into a fresh database', () => {const { db, cleanup } = createTempDb();try {diff --cc apps/desktop/src/main/localDb/mapper.tsindex 2d0be96fd5,9ea4d8e542..9673b8dfbb--- a/apps/desktop/src/main/localDb/mapper.ts+++ b/apps/desktop/src/main/localDb/mapper.ts@@@ -699,9 -699,9 +699,10 @@@ export function scheduleToCamel(row: ScintervalMs: row.intervalMs ?? undefined,agentKind: row.agentKind as SchedulerAgentKind,modelAgentKind: row.modelAgentKind ?? undefined,+ modelAgentDeviceId: row.modelAgentDeviceId ?? undefined,model: row.model ?? undefined,providerId: row.providerId ?? undefined,+ agentDeviceId: row.agentDeviceId ?? undefined,effort: row.effort ?? undefined,fastMode: (row.fastMode ?? false),workspaceKind: normalizeWorkspaceKind(row.workspaceKind),@@@ -752,9 -752,9 +753,10 @@@ export function scheduleCreateToRow(s:intervalMs: s.intervalMs ?? null,agentKind: s.agentKind,modelAgentKind: s.modelAgentKind ?? null,+ modelAgentDeviceId: s.modelAgentDeviceId ?? null,model: s.model ?? null,providerId: s.providerId ?? null,+ agentDeviceId: s.agentDeviceId ?? null,effort: (s.effort as ScheduleInsert['effort']) ?? null,fastMode: (s.fastMode ?? false),workspaceKind: s.workspaceKind ?? 'project',@@@ -808,9 -808,9 +810,10 @@@ export function schedulePatchToRow(patcif (hasKey(patch, 'intervalMs')) out.intervalMs = patch.intervalMs ?? null;if (hasKey(patch, 'agentKind')) out.agentKind = patch.agentKind as ScheduleInsert['agentKind'];if (hasKey(patch, 'modelAgentKind')) out.modelAgentKind = patch.modelAgentKind ?? null;+ if (hasKey(patch, 'modelAgentDeviceId')) out.modelAgentDeviceId = patch.modelAgentDeviceId ?? null;if (hasKey(patch, 'model')) out.model = patch.model ?? null;if (hasKey(patch, 'providerId')) out.providerId = patch.providerId ?? null;+ if (hasKey(patch, 'agentDeviceId')) out.agentDeviceId = patch.agentDeviceId ?? null;if (hasKey(patch, 'effort')) out.effort = (patch.effort as ScheduleInsert['effort']) ?? null;if (hasKey(patch, 'fastMode')) out.fastMode = (patch.fastMode ?? false);if (hasKey(patch, 'workspaceKind')) out.workspaceKind = patch.workspaceKind ?? 'project';diff --cc apps/desktop/src/main/maker-host/model-route-guard-live.tsindex 4da43d5f06,26ace3e229..27d556cee9--- a/apps/desktop/src/main/maker-host/model-route-guard-live.ts+++ b/apps/desktop/src/main/maker-host/model-route-guard-live.ts@@@ -300,20 -299,24 +300,24 @@@ export async function resolveLenientSesreturn route;}- /** Resolve one provider-specific snapshot after route admission for fresh and bound sends. */+ /**+ * Resolve one provider-specific snapshot after route admission for fresh and bound sends.+ * An Agent on another computer resolves against that computer's authorized catalog and+ * never falls back to a local provider with the same id.+ */export async function resolveScheduledModelSelectionLive(selection: ScheduledModelSelection,- location?: { agentDeviceId: string },+ readRemoteProviders?: (agentDeviceId: string) => Promise<ProviderView[]>,): Promise<ScheduledModelSelection> {- if (location?.agentDeviceId) {- const { readRemoteProviderRoute } = await import('../remote-agent/controller/deviceCatalog.js');- const { provider } = await readRemoteProviderRoute({- agentDeviceId: location.agentDeviceId,- agentKind: selection.agentKind,- providerId: selection.providerId,- model: selection.model,- });- return resolveScheduledModelSelection({ ...selection, providerId: provider.id }, [provider]);+ if (selection.agentDeviceId) {+ if (!readRemoteProviders) throw new Error('Scheduled remote model resolution is not available');+ let views: ProviderView[] = [];+ const rejection = await checkDeviceRoute(async () => {+ views = await readRemoteProviders(selection.agentDeviceId!);+ return views;+ }, selection.agentKind, selection.providerId, selection.model);+ if (rejection) throw new Error(`Scheduled remote model route unavailable: ${rejection}`);+ return resolveScheduledModelSelection(selection, views);}const providers = await getDesktopProviderService().listProviders({allowSideEffects: false, catalog: getActiveCatalog(),diff --cc apps/desktop/src/main/maker-ipc/__tests__/scheduledModelSelection.test.tsindex 0abb6c2847,e68182e145..a1812d5c06--- a/apps/desktop/src/main/maker-ipc/__tests__/scheduledModelSelection.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/scheduledModelSelection.test.ts@@@ -13,7 -13,6 +13,7 @@@ describe('one-run automation model preffunction scopeFixture(effort: ScheduledModelSelection['effort'] | '' = 'high',fastMode: ScheduledModelSelection['fastMode'] = true,- agentDeviceId?: string | null,++ agentDeviceId: string | null = null,) {const original: ScheduledModelSelection = {agentKind: 'codex', model: 'owner-model', providerId: 'owner-provider',@@@ -48,14 -45,6 +48,25 @@@await scope.restore('task');expect(h.state()).toEqual({ profile: h.original, baseline: null });});+ // Unit: location is part of the durable restore record, including explicit local null.+ it.each([null, 'shared:owner'])('restores the original Agent location %j after restart', async (device) => {+ const h = scopeFixture('high', false, device);+ const scopeId = await h.scope.begin('task');+ h.automate();+ await createScheduledModelScope(h.deps).restore('task', scopeId);+ expect(h.state()).toEqual({ profile: h.original, baseline: null });+ });++ // Merge regression, unit: old baselines have no location. A repeated automation++ // must capture that missing axis before moving the task, preserving the old model.++ it.each([null, 'shared:owner'])('upgrades a legacy baseline at %j before a location change', async (device) => {++ const h = scopeFixture('high', false, device);++ const { agentDeviceId: _location, ...legacy } = h.original;++ await h.deps.write('task', { ...legacy, scopeId: 'legacy-scope' });++ expect(await h.scope.begin('task')).toBe('legacy-scope');++ h.automate();++ await createScheduledModelScope(h.deps).restore('task', 'legacy-scope');++ expect(h.state()).toEqual({ profile: h.original, baseline: null });++ });// PR #6559 + #6579 integration: the persisted scope must restore an// Ultrafast owner after automation/restart. Existing cases used booleans;// minimal failure is baseline JSON with fastMode='ultrafast'. Unit tier.diff --cc apps/desktop/src/main/maker-ipc/schedule.tsindex ece7bc6b0e,807e621b40..4079287a81--- a/apps/desktop/src/main/maker-ipc/schedule.ts+++ b/apps/desktop/src/main/maker-ipc/schedule.ts@@@ -315,8 -311,8 +315,9 @@@ function buildCreateScheduleInputmanual: overrides.manual,intervalMs: overrides.intervalMs,agentKind: overrides.agentKind ?? template.agentKind ?? 'claude-code',+ agentDeviceId: overrides.agentDeviceId,modelAgentKind: overrides.modelAgentKind,+ modelAgentDeviceId: overrides.modelAgentDeviceId,model: overrides.model ?? template.model,providerId: overrides.providerId ?? template.providerId,effort: overrides.effort ?? template.effort,diff --cc apps/desktop/src/main/maker-ipc/scheduledModelSelection.tsindex bfcd62eaa2,a265cd0f24..70ecf1b314--- a/apps/desktop/src/main/maker-ipc/scheduledModelSelection.ts+++ b/apps/desktop/src/main/maker-ipc/scheduledModelSelection.ts@@@ -44,9 -41,9 +43,17 @@@ export function createScheduledModelScoassertOwner(owner);if (!row) return undefined;const existing = parseScheduledModelBaseline(row.baseline);-- if (existing) return existing.scopeId;++ if (existing) {++ // Older baselines predate location overrides. Capture the current location++ // before this automation can move it, without replacing the owner's model.++ if (existing.agentDeviceId === undefined) {++ await deps.write(sessionId, { ...existing, agentDeviceId: row.profile.agentDeviceId ?? null });++ }++ return existing.scopeId;++ }const scopeId = deps.createId();-- await deps.write(sessionId, { ...row.profile, effort: row.profile.effort || null, scopeId });++ await deps.write(sessionId, { ...row.profile, agentDeviceId: row.profile.agentDeviceId ?? null,++ effort: row.profile.effort || null, scopeId });return scopeId;},async restore(sessionId: string, expectedScopeId?: string): Promise<void> {@@@ -121,17 -113,17 +128,20 @@@ export async function applyScheduledMod},): Promise<ScheduledModelSelection> {const target = await deps.getTarget();- // The runner owns missing/archived target recovery, including persistent-task rebinding.+ // The runner restores ordinary archived targets before selection and owns+ // deleted/missing-target rebinding for persistent tasks.+ // Its replacement resolves at the schedule's saved location. Do not query the old+ // target's catalog: that device may be offline or its provider share revoked.if (!target || target.status === 'archived' || target.status === 'deleted') {- return deps.resolveSelection(selection);+ return selection;}if (deps.isBusy()) throw new ScheduledModelSelectionBusyError('Scheduled model selection waits for the current turn');- assertScheduledHarnessSupported(target, selection.agentKind);- const resolved = await deps.resolveSelection(selection);- if (target.agentKind !== resolved.agentKind) {+ assertScheduledHarnessSupported(target, selection.agentKind, selection.agentDeviceId);+ const resolved = await deps.resolveSelection({ ...selection,+ ...(selection.agentDeviceId === undefined && target.agentDeviceId !== undefined+ ? { agentDeviceId: target.agentDeviceId } : {}),+ });+ if (target.agentKind !== resolved.agentKind || (target.agentDeviceId ?? null) !== (resolved.agentDeviceId ?? null)) {const result = await deps.switchHarness(resolved);if (!result.engineReady || result.retryPending) throw new Error('Scheduled Harness switch did not become ready');}diff --cc apps/desktop/src/main/scheduler-host/__tests__/runnerModelSelection.test.tsindex aef3f7bfa1,1aa831252a..771f7b73b7--- a/apps/desktop/src/main/scheduler-host/__tests__/runnerModelSelection.test.ts+++ b/apps/desktop/src/main/scheduler-host/__tests__/runnerModelSelection.test.ts@@@ -332,27 -332,9 +332,31 @@@ describe('MakerScheduleRunner model selmocks.getSessionRowSnapshot.mockResolvedValue({ status: 'active' });});+ // Integration: a new automation must pass the remote route to createSession,+ // retain its workspace and avoid consulting a conflicting local provider copy.+ it.each(['claude-code', 'codex', 'pi'] as const)('creates a remote %s automation on the chosen source', async (agentKind) => {+ const h = createSessionHarness();+ Object.assign(h.session, { agentKind, model: 'remote-model', setFastMode: vi.fn() });+ const checkModelRoute = vi.fn(async () => ({ kind: 'reject' as const, reason: 'explicit-source-disabled' as const }));+ const resolveModelSelection = vi.fn(async (choice: Parameters<typeof resolveScheduledModelSelection>[0]) => ({ ...choice, effort: 'high' as const }));+ const harness = createRunnerHarness(h, null, { resolveModelSelection, checkModelRoute });+ const schedule = baseSchedule({ agentKind, modelAgentKind: agentKind, modelAgentDeviceId: 'shared:owner',+ model: 'remote-model', providerId: 'remote-source', effort: 'high' });+ const saved = structuredClone(schedule);+ const opts = await fireToCompletion(harness, h, schedule);+ expect(opts).toMatchObject({ agentDeviceId: 'shared:owner', agentKind, model: 'remote-model',+ providerId: 'remote-source', workingDir: '/work', effort: 'high' });- expect(resolveModelSelection).toHaveBeenCalledWith(expect.objectContaining({ agentDeviceId: 'shared:owner' }));++ expect(resolveModelSelection).toHaveBeenCalledWith(expect.objectContaining({ agentDeviceId: 'shared:owner' }),++ { agentDeviceId: 'shared:owner' });+ expect(checkModelRoute).not.toHaveBeenCalled();+ expect(schedule).toEqual(saved);+ });++ // Integration: follow the production runner from model override through completion/failure.+ // The previous route tests asserted the automation model only, never the next user's choice.+ // 2026-10-23 regression: completion restored the runtime and rebuilt a finished+ // task's context. Unit tier: real runner success/failure must leave the native+ // model untouched; the persisted owner preference is applied by the next send.it.each([['legacy', 'success'], ['explicit', 'success'],['legacy', 'failure'], ['explicit', 'failure'],@@@ -398,7 -401,98 +423,119 @@@});describe('resolved automation selection survives the full fire', () => {- it.each(['active', 'archived', 'missing'] as const)('uses the explicit Pi route for a %s Codex target', async (status) => {++ // Merge regression, unit: a legacy remote default must not mask an explicit++ // local override. Cover fresh creation and persistent replacement via fire.++ it.each([false, true])('honors local selection over a saved remote default (replacement=%s)', async (replacement) => {++ const h = createSessionHarness();++ Object.assign(h.session, { agentKind: 'codex', model: 'gpt-5.5' });++ mocks.getSessionRowSnapshot.mockResolvedValue({ status: 'deleted', agentDeviceId: 'relocated' });++ const resolveModelSelection = vi.fn(async (choice) => choice);++ const harness = createRunnerHarness(h, null, { resolveModelSelection,++ acquirePendingAgentSwitch: async (_id, _signal, selection) => ({ release: vi.fn(), selection: selection! }),++ });++ harness.runner.attachScheduler({ update: vi.fn(), isRunSilenced: () => false } as unknown as Scheduler);++ await fireToCompletion(harness, h, baseSchedule({ agentKind: 'codex', modelAgentKind: 'codex',++ agentDeviceId: 'studio', modelAgentDeviceId: '', model: 'gpt-5.5', providerId: 'local-provider',++ ...(replacement ? { targetSessionId: h.session.id, persistentSession: true } : {}),++ }));++ expect(harness.createSession.mock.calls[0][0].agentDeviceId).toBeUndefined();++ expect(resolveModelSelection).toHaveBeenCalledWith(expect.objectContaining({++ agentDeviceId: null, providerId: 'local-provider',++ }));++ });+++ // PR #6832: fire must resolve a replacement at the saved location from the saved+ // preferences, not the relocated target's clamped copy. Existing replacement cases+ // used identical catalogs. Minimal input: deleted persistent target on another+ // device, with different effort/Fast support. Tier: unit (in-memory host).+ // Windows standalone: 14.30s (collection 10.08s, 72 tests 3.85s). Reuses the+ // existing file-level imports/fixture; no module resets or new real I/O.+ it.each([+ { agentDeviceId: undefined, target: { status: 'deleted' } },+ { agentDeviceId: 'studio', target: { status: 'deleted' } },+ { agentDeviceId: undefined, target: { status: 'archived', source: 'bot' } },+ { agentDeviceId: undefined, target: { status: 'archived', orcaRole: 'worker' as const } },+ { agentDeviceId: undefined, target: { status: 'archived', orcaRemoteLead: '{"leadSessionId":"lead"}' } },+ { agentDeviceId: undefined, target: { status: 'archived', source: 'review' } },+ ])('preserves persistent replacement routing for an unavailable managed/deleted target: %j', async ({ agentDeviceId, target }) => {+ const h = createSessionHarness();+ Object.assign(h.session, { agentKind: 'codex', model: 'gpt-5.5' });+ mocks.getSessionRowSnapshot.mockResolvedValue({ ...target, agentDeviceId: 'relocated' });+ const resolveModelSelection = vi.fn(async (choice) => ({ ...choice, effort: 'high' as const }));+ const harness = createRunnerHarness(h, null, {+ acquirePendingAgentSwitch: async () => ({ release: vi.fn(), selection: {+ agentKind: 'codex', model: 'gpt-5.5', providerId: 'relocated-provider',+ effort: 'low', fastMode: false,+ } }),+ resolveModelSelection,+ });+ harness.runner.attachScheduler({ update: vi.fn(), isRunSilenced: () => false } as unknown as Scheduler);+ const schedule = baseSchedule({ targetSessionId: h.session.id, persistentSession: true,+ agentDeviceId, agentKind: 'codex', modelAgentKind: 'codex', model: 'gpt-5.5',+ providerId: 'saved-provider', effort: 'ultra', fastMode: true });+ const opts = await fireToCompletion(harness, h, schedule);+ expect(resolveModelSelection.mock.calls[0]).toEqual([+ expect.objectContaining({ providerId: 'saved-provider', effort: 'ultra', fastMode: true }),+ ...(agentDeviceId ? [{ agentDeviceId }] : []),+ ]);+ expect(opts).toMatchObject({ providerId: 'saved-provider', effort: 'high' });+ expect(harness.createSession.mock.calls[0][0].agentDeviceId).toBe(agentDeviceId);+ });++ // PR #6832: the old rebinding fixture returned a successful catalog snapshot.+ // Exercise the real selection entry with an unavailable old catalog; fire must+ // still create at the saved location with its route (unit, in-memory host).+ it.each([undefined, 'studio'])('rebinds at %s when the deleted target catalog is unavailable', async (agentDeviceId) => {+ const h = createSessionHarness();+ Object.assign(h.session, { agentKind: 'codex', model: 'gpt-5.5' });+ mocks.getSessionRowSnapshot.mockResolvedValue({ status: 'deleted', agentDeviceId: 'relocated' });+ const oldCatalog = vi.fn(async () => { throw new Error('old target offline or share revoked'); });+ const resolveModelSelection = vi.fn(async (choice) => ({ ...choice, effort: 'high' as const }));+ const harness = createRunnerHarness(h, null, {+ acquirePendingAgentSwitch: async (_id, _signal, selection) => ({+ release: vi.fn(),+ selection: await applyScheduledModelSelection(selection!, {+ getTarget: async () => ({ agentKind: 'codex', status: 'deleted' }),+ isBusy: () => false,+ resolveSelection: oldCatalog,+ switchHarness: async () => ({ engineReady: true }),+ applyModel: async () => {},+ }),+ }),+ resolveModelSelection,+ });+ harness.runner.attachScheduler({ update: vi.fn(), isRunSilenced: () => false } as unknown as Scheduler);+ const opts = await fireToCompletion(harness, h, baseSchedule({+ targetSessionId: h.session.id, persistentSession: true, agentDeviceId,+ agentKind: 'codex', modelAgentKind: 'codex', model: 'gpt-5.5', providerId: 'saved-provider',+ }));+ expect(opts).toMatchObject({ providerId: 'saved-provider', effort: 'high' });+ expect(harness.createSession.mock.calls[0][0].agentDeviceId).toBe(agentDeviceId);+ expect(oldCatalog).not.toHaveBeenCalled();+ expect(resolveModelSelection.mock.calls[0]).toEqual([+ expect.objectContaining({ providerId: 'saved-provider' }),+ ...(agentDeviceId ? [{ agentDeviceId }] : []),+ ]);+ });++ // PR #6832: existing remote coverage only created new tasks. Cold resume and+ // model-triggered rebuild must dispatch at the bound row's current location,+ // even when the automation still saves its original location. Tier: unit.+ it.each(['cold', 'rebuild'] as const)('keeps the bound task location during %s resume', async (mode) => {+ const h = createSessionHarness();+ if (mode === 'rebuild') Object.assign(h.session, { requiresModelSwitchRebuild: async () => true });+ mocks.getSessionRowSnapshot.mockResolvedValue({ status: 'active', agentDeviceId: 'relocated' });+ const harness = createRunnerHarness(h, { model: h.session.model, workDir: '/work', sdkSessionId: 'native-history' }, {+ sessionAlive: mode === 'rebuild',+ });+ const opts = await fireToCompletion(harness, h, baseSchedule({+ targetSessionId: h.session.id, persistentSession: true, agentDeviceId: 'original',+ }));+ expect(opts).toMatchObject({ agentDeviceId: 'relocated', resumeSessionId: 'native-history' });+ expect(harness.closeSession).toHaveBeenCalledTimes(mode === 'rebuild' ? 1 : 0);+ });++ it.each(['active', 'deleted', 'missing'] as const)('uses the explicit Pi route for a %s Codex target', async (status) => {const h = createSessionHarness();Object.assign(h.session, { agentKind: 'pi', model: 'shared-model' });const release = vi.fn();diff --cc apps/desktop/src/main/scheduler-host/__tests__/scriptCapabilityBroker.test.tsindex 9d32a705a9,9f113df964..e3c18350e4--- a/apps/desktop/src/main/scheduler-host/__tests__/scriptCapabilityBroker.test.ts+++ b/apps/desktop/src/main/scheduler-host/__tests__/scriptCapabilityBroker.test.ts@@@ -545,20 -599,6 +599,23 @@@ describe('SchedulerScriptCapabilityBrokexpect(result).toMatchObject({ target_session_id: 'session-1', wake_kind: 'created' });});+ // Integration regression: a persisted remote route must never become local+ // create defaults merely because sessions.dispatch omits a target task.- it('rejects remote script-dispatch defaults before opening a local session', async () => {++ it.each([++ { modelAgentDeviceId: 'shared:owner', modelAgentKind: 'codex' as const },++ { agentDeviceId: 'studio' },++ ])('rejects remote script-dispatch defaults before opening a local session (%j)', async (location) => {+ await expect(new SchedulerScriptCapabilityBroker().call(+ { method: 'sessions.dispatch', params: { message: 'run task' } },+ new Set(['sessions.dispatch']),- { schedule: schedule({ modelAgentDeviceId: 'shared:owner', modelAgentKind: 'codex' }) },++ { schedule: schedule(location) },+ )).rejects.toMatchObject({+ code: 'PRECONDITION_FAILED',+ message: expect.stringContaining('script execution does not support remote model sources'),+ });+ expect(sendToSessionMock).not.toHaveBeenCalled();+ });+it('resolves blank Pi script-dispatch defaults as one model/provider route', async () => {sendToSessionMock.mockResolvedValue({ok: true,diff --cc apps/desktop/src/main/scheduler-host/index.tsindex a4cc15b9c4,57d7e4bbab..6a3ab0addb--- a/apps/desktop/src/main/scheduler-host/index.ts+++ b/apps/desktop/src/main/scheduler-host/index.ts@@@ -132,12 -131,10 +132,15 @@@ async function startSchedulerInternal(donUndispatchedUserTurn: deps.onUndispatchedUserTurn,findUsageLimitWait: findSchedulerUsageLimitWait,acquirePendingAgentSwitch: acquirePendingAgentSwitchForDirectSend,- preserveModelPreferences: preserveScheduledModelPreferencesUnderLock,+ prepareModelPreferences: prepareScheduledModelPreferencesUnderLock,onModelDispatched: recordDispatchedModel,applyPiModelSelectionUnderLock: applyPiImModelSelectionUnderLock,- resolveModelSelection: (selection) => resolveScheduledModelSelectionLive(selection, async (agentDeviceId) => [- (await readRemoteProviderRoute({ ...selection, agentDeviceId })).provider,- ]),- resolveModelSelection: resolveScheduledModelSelectionLive,++ resolveModelSelection: (selection, location) => {++ const route = { ...selection, agentDeviceId: selection.agentDeviceId === undefined ? location?.agentDeviceId : selection.agentDeviceId };++ return resolveScheduledModelSelectionLive(route, async (agentDeviceId) => [++ (await readRemoteProviderRoute({ ...route, agentDeviceId })).provider,++ ]);++ },onSessionCreated: broadcastSessionCreated,// 停用轴裁决:每次 fire 前判保存路由是否已被用户停用(见 runner deps 注释)。checkModelRoute: verdictForModelRoute,diff --cc apps/desktop/src/main/scheduler-host/project-automation-loader.tsindex e7928e827c,3c0104603d..536441d0cb--- a/apps/desktop/src/main/scheduler-host/project-automation-loader.ts+++ b/apps/desktop/src/main/scheduler-host/project-automation-loader.ts@@@ -458,9 -459,10 +460,11 @@@ function scheduleConfigToCreateInputagentKind: config.agentKind ?? 'claude-code',// 恒带 key:配置删除显式选择后,reconcile 清除已保存的标记。modelAgentKind: config.modelAgentKind,+ modelAgentDeviceId: config.modelAgentDeviceId,model: config.model,providerId: config.providerId,+ // 恒带 key:配置删掉运行位置时清除已保存的位置。+ agentDeviceId: config.agentDeviceId,effort: config.effort,fastMode: config.fastMode,workspaceKind: 'project',@@@ -500,9 -502,9 +504,10 @@@ export function schedulesDifferschedule.intervalMs !== expected.intervalMs ||schedule.agentKind !== expected.agentKind ||schedule.modelAgentKind !== expected.modelAgentKind ||+ schedule.modelAgentDeviceId !== expected.modelAgentDeviceId ||schedule.model !== expected.model ||(schedule.providerId ?? undefined) !== (expected.providerId ?? undefined) ||+ (schedule.agentDeviceId ?? undefined) !== (expected.agentDeviceId ?? undefined) ||schedule.effort !== expected.effort ||(schedule.fastMode ?? false) !== (expected.fastMode ?? false) ||schedule.workspaceKind !== expected.workspaceKind ||diff --cc apps/desktop/src/main/scheduler-host/runner.tsindex 355cc6c8d0,8d6ec267c9..86041df1b8--- a/apps/desktop/src/main/scheduler-host/runner.ts+++ b/apps/desktop/src/main/scheduler-host/runner.ts@@@ -1184,6 -1198,13 +1199,14 @@@ export class MakerScheduleRunner implemconst explicitProviderId = schedule.providerId?.trim() ? schedule.providerId.trim() : null;const defaultRouteProviderId = explicitProviderId ?? (isHeartbeat ? heartbeatProviderId : null);const followsNewTaskDefault = !rawModel?.trim();+ // 新建任务的 Agent 在另一台电脑运行:模型与来源属于那台的已授权目录,本机的默认路由、+ // 停用轴与能力表都不适用,统一交给 resolveModelSelection 按那台目录解析。绑定的任务+ // 仍存在时运行位置跟随它(heartbeat 分支由 acquirePendingAgentSwitch 按任务所在位置解析)。- const freshAgentDeviceId = isHeartbeat ? null : schedule.agentDeviceId?.trim() || null;++ const freshAgentDeviceId = isHeartbeat ? null++ : (schedule.modelAgentDeviceId ?? schedule.agentDeviceId)?.trim() || null;+ if (freshAgentDeviceId && followsNewTaskDefault) {+ throw new Error('schedule route unavailable: a remote agent location requires an explicit model');+ }// Fresh Claude schedules must freeze the same provider rail the UI would use for this model.// Leaving providerId null delegates credential selection to the legacy auth fallback, which can// silently choose the Cindy gateway even when the only usable source is an Anthropic subscription.@@@ -1246,10 -1267,6 +1269,10 @@@(isHeartbeat ? heartbeatProviderId : null) ??dynamicDefaultRoute?.providerId ??null;+ // Remote Agent routes use that device's authorized catalog, never local credentials.+ const agentDeviceId = resolvedSelection?.agentDeviceId !== undefined+ ? resolvedSelection.agentDeviceId- : (isHeartbeat ? heartbeatAgentDeviceId : schedule.modelAgentDeviceId) || null;++ : (isHeartbeat ? heartbeatAgentDeviceId : freshAgentDeviceId) || null;// 停用轴准入(PR #744 review):每次 fire 都是新的付费调用,不属于「运行中的会话// 不打断」豁免 —— 保存过的路由被用户停用后,本次 run 必须以明确错误失败(run 历史// 可见),不能继续经停用路由扣费;隐式默认落点被停用而有启用替代拷贝时改路由过去。@@@ -1266,12 -1283,11 +1289,12 @@@reroutedProviderId = verdict.providerId;}}- if (!isHeartbeat && schedule.modelAgentKind && !resolvedSelection) {+ if (!isHeartbeat && (schedule.modelAgentKind || freshAgentDeviceId) && !resolvedSelection) {if (!this.deps.resolveModelSelection)throw new Error('Scheduled model selection is not available');- resolvedSelection = await this.deps.resolveModelSelection({+ const selection: ScheduledModelSelection = {agentKind: effectiveAgentKind,+ agentDeviceId,model,providerId: createProviderId,effort: (schedule.effort as Effort | undefined) ?? null,@@@ -1346,7 -1365,7 +1372,7 @@@reroutedProviderId ??materializedDefaultProviderId ??currentProviderId;-- const credentialSwitchInput = liveSession++ const credentialSwitchInput = liveSession && !agentDeviceId? {agentKind: liveSession.agentKind,remoteHostId: liveSession.remoteHostId,@@@ -2475,9 -2496,19 +2502,20 @@@: schedule.prompt,origin,onPreparing: async () => {+ this.assertQueuedModelSelection(this.deps.maker.getSession(sessionId), routingBaseline.resolvedSelection);- if (schedule.targetSessionId && hasScheduledModelOverride(schedule) && this.deps.preserveModelPreferences) {- holder.restoreModelPreferences = await this.deps.preserveModelPreferences?.(sessionId);+ if (schedule.targetSessionId && this.deps.prepareModelPreferences) {+ const override = hasScheduledModelOverride(schedule);+ await this.deps.prepareModelPreferences(sessionId, override);+ if (!override) {+ // The previous automation can have left its native route in place+ // while this item waited. Use the restored owner route at dispatch.+ const meta = await this.deps.maker.getSessionMeta(sessionId);+ routingBaseline = {+ ...routingBaseline, model: meta?.model, agentKind: meta?.agentKind,+ effort: meta?.effort, fastMode: meta?.fastMode,+ providerId: getSessionProvider(sessionId) ?? null,+ };+ }}const preparingLive = this.deps.maker.getSession(sessionId);if ((preparingLive?.agentKind ?? routingBaseline.agentKind ?? schedule.agentKind) !== 'pi') return;diff --cc apps/desktop/src/main/scheduler-host/script-capability-broker.tsindex bf10a4e0cb,38bdc6e87f..6b315d9413--- a/apps/desktop/src/main/scheduler-host/script-capability-broker.ts+++ b/apps/desktop/src/main/scheduler-host/script-capability-broker.ts@@@ -218,9 -221,6 +221,9 @@@ export class SchedulerScriptCapabilityB/** 新建任务的配置:模型留空时按新建任务口径实时解析,不写死型号。 */private async createDefaultsFor(schedule: Schedule) {- if (schedule.modelAgentDeviceId) {++ if (schedule.modelAgentDeviceId ?? schedule.agentDeviceId) {+ fail('PRECONDITION_FAILED', 'script execution does not support remote model sources; select a local model before switching modes');+ }const explicitProviderId = schedule.providerId?.trim() || null;const dynamicDefaultRoute = !schedule.model?.trim()? await this.deps.resolveDefaultModelRoute?.(schedule.agentKind, explicitProviderId) ?? nulldiff --cc apps/desktop/src/renderer/__tests__/schedulerModelPopoverOverlay.test.tsxindex 537afe196e,58c52ad5ec..4e5f5c34ca--- a/apps/desktop/src/renderer/__tests__/schedulerModelPopoverOverlay.test.tsx+++ b/apps/desktop/src/renderer/__tests__/schedulerModelPopoverOverlay.test.tsx@@@ -82,9 -82,14 +82,16 @@@ vi.mock('@/components/new-chat/ModelSel}));vi.mock('@/hooks/useAvailableAgents', () => ({ useModelPickerAgents: () => ['claude-code', 'codex', 'pi'] }));+// These cases exercise the popover; location discovery is covered by useWorkerAgentDevices.+vi.mock('@/hooks/useModelRouteDevices', () => ({ useModelRouteDevices: () => ({ devices: undefined }) }));+ // PR #6832: these local popover interaction tests now also import remote location+ // discovery. Keep the unit fixture local; loading real account/chat state made+ // collection fail before the existing selection/refresh assertions could run.+ vi.mock('@/hooks/useModelRouteDevices', () => ({+ useModelRouteDevices: () => ({ leadAgentDeviceId: null, devices: [] }),+ }));+vi.mock('@/hooks/useAgentCapabilities', () => ({getCachedCapabilities: () => null,useAgentCapabilities: () => ({diff --cc apps/desktop/src/renderer/features/scheduler/components/ScheduleFormDialog.tsxindex 1983616205,2f915b711b..f154596bf8--- a/apps/desktop/src/renderer/features/scheduler/components/ScheduleFormDialog.tsx+++ b/apps/desktop/src/renderer/features/scheduler/components/ScheduleFormDialog.tsx@@@ -1,5 -1,5 +1,5 @@@import { ErrorNotice } from '@/components/ui/error-notice';--import { useCallback, useEffect, useMemo, useState } from 'react';++import { useCallback, useEffect, useMemo, useRef, useState } from 'react';import { useNavigate } from 'react-router-dom';import * as Dialog from '@radix-ui/react-dialog';import { Check, FolderOpen, Info, Play, Sparkles, X } from 'lucide-react';@@@ -152,6 -148,15 +148,17 @@@ export function ScheduleFormDialog(const boundSessionReference = isBound? boundSessionReferences.get(form.targetSessionId): undefined;- // 绑定任务的 Agent 所在电脑(null = 本机)。运行位置跟随任务,模型面板只列这一处。++ // An explicit automation selection wins; legacy locations only seed fresh runs.+ const boundAgentDeviceId = boundSessionReference?.agentDeviceId ?? null;- const selectedAgentDeviceId = isBound ? boundAgentDeviceId : form.agentDeviceId || null;++ const selectedAgentDeviceId = form.modelAgentDeviceId !== undefined++ ? form.modelAgentDeviceId || null++ : isBound ? boundAgentDeviceId : form.agentDeviceId || null;+ const caps = useAgentCapabilities(form.agentKind, selectedAgentDeviceId ?? undefined);+ const localProviders = useProviders();+ const deviceProviders = useDeviceProviders(selectedAgentDeviceId ?? undefined);+ const { providers, loading: providersLoading } = selectedAgentDeviceId ? deviceProviders : localProviders;+ // Do not calibrate saved choices against a provisional local or loading snapshot.- const modelCatalogReady = (!isBound || !!boundSessionReference) && !caps.loading && !providersLoading;++ const modelCatalogReady = (!isBound || form.modelAgentDeviceId !== undefined || !!boundSessionReference) && !caps.loading && !providersLoading;const hideWorkspaceFields = runMode === 'bound' || isBound;const [submitting, setSubmitting] = useState(false);const [mode, setMode] = useState<'gallery' | 'form'>('form');@@@ -252,9 -257,14 +259,14 @@@const description = hookGenDesc.trim();if (!description || hookGenerating) return;const hasSessionTarget = hasRealBinding(form);- const resolveBoundSessionRoute = needsBoundSessionGenerationRouteResolution(form);+ // 脚本在本机生成。Agent 在另一台电脑时它的模型与来源只在那台可用,改用本机的+ // 辅助模型兜底链,不把那台的来源 id 当成本机来源。- const remoteAgentLocation = hasSessionTarget ? boundAgentDeviceId : form.agentDeviceId || null;++ const remoteAgentLocation = selectedAgentDeviceId;+ const resolveBoundSessionRoute = !remoteAgentLocation && needsBoundSessionGenerationRouteResolution(form);const inheritsBoundSessionModel = usesBoundSessionGenerationModel(form);- const providerId = resolveBoundSessionRoute+ const providerId = remoteAgentLocation+ ? undefined+ : resolveBoundSessionRoute? form.providerId.trim() || undefined: resolveScheduleGenerationProviderId({providers,@@@ -274,11 -284,10 +286,12 @@@description,scheduleName: form.name.trim() || undefined,providerId: providerId ?? undefined,- modelAgentDeviceId: form.modelAgentDeviceId,++ // Remote selections use the existing local utility-model fallback above.++ modelAgentDeviceId: undefined,// bound 任务的缺省模型/来源维度由 main 按绑定会话补齐;provider/model 的显式// 覆盖仍原样透传。persistent 任务即使已回写 targetSessionId,也按任务级选择生成。- agentKind: resolveBoundSessionRoute ? undefined : form.agentKind,- model: inheritsBoundSessionModel ? undefined : form.model.trim() || undefined,+ agentKind: resolveBoundSessionRoute || remoteAgentLocation ? undefined : form.agentKind,+ model: inheritsBoundSessionModel || remoteAgentLocation ? undefined : form.model.trim() || undefined,// 绑定会话任务:workingDir 不发(表单残留值可能是改绑前的过期项目目录,// 显式值会压过会话解析),真实 cwd 由 main 按会话 meta.workDir 解析 ——// 落盘目录/自测环境与生产运行一致@@@ -308,7 -317,8 +321,7 @@@providers,form.name,form.providerId,- form.modelAgentDeviceId,- form.agentDeviceId,- boundAgentDeviceId,++ selectedAgentDeviceId,form.effort,form.agentKind,form.model,@@@ -357,7 -367,7 +370,7 @@@setField('recurring', template.recurring);setField('manual', false);}-- applyTemplateAgentFields(template);++ applyTemplateAgentFields(template, localProviders.providers);if (template.useWorktree !== undefined) setField('useWorktree', template.useWorktree);// useWorktree 只在 project workspace 且无会话绑定时会被 buildScheduleInput 保留;// 模板要求 worktree 时把表单切到 project 模式并清掉绑定会话(绑定与 worktree@@@ -381,11 -391,11 +394,18 @@@setParamValues(initParams);setPromptDirty(false);setMode('form');-- }, [setField, applyTemplateAgentFields]);++ }, [setField, applyTemplateAgentFields, localProviders.providers]);// Must run after the open/reset effect above so template fields override fresh defaults.++ const appliedInitialTemplate = useRef<string | null>(null);useEffect(() => {-- if (!open || !initialTemplate || isEdit || isProjectAutomationMode) return;++ if (!open || !initialTemplate || isEdit || isProjectAutomationMode) {++ appliedInitialTemplate.current = null;++ return;++ }++ // Catalog refreshes may change the callback, but must not replace a user's draft.++ if (appliedInitialTemplate.current === initialTemplate.id) return;++ appliedInitialTemplate.current = initialTemplate.id;applyTemplateToForm(initialTemplate);}, [open, initialTemplate, isEdit, isProjectAutomationMode, applyTemplateToForm]);@@@ -451,11 -461,13 +471,13 @@@// form.model 为空时回填默认模型(三级回退,所见即所存)。// 覆盖历史遗留的空 model 任务(编辑打开时回填);第三级(新建任务默认)要等供应商// 清单到位才能算出,算不出时保持留空,runner 按同一口径实时解析。-- // ⚠️ heartbeat 形态(targetSessionId 非空,含 '__pending__')必须跳过:++ // ⚠️ heartbeat 跟随模式(targetSessionId 非空且无显式 Harness)必须跳过:// 空 model = "跟随会话"是有效语义,回填会把 MCP 建的跟随任务静默落成// 显式模型,下次 fire runner setModel 反向改掉绑定会话的模型。useEffect(() => {-- if (form.targetSessionId.trim()) return;++ if (form.targetSessionId.trim() && !form.modelAgentKind) return;+ // Local recent-model preferences do not describe another computer's catalog.+ if (selectedAgentDeviceId) return;if (form.model) return;// 默认路由限定在表单已选的来源内,模型与来源成对回填(已选来源保持不变)。const route = getScheduleDefaultRoute(@@@ -466,13 -478,21 +488,21 @@@if (!route.model) return;setField('model', route.model);if (route.providerId && !form.providerId.trim()) setField('providerId', route.providerId);- }, [form.model, form.agentKind, form.targetSessionId, form.providerId, setField, providers, providersLoading]);- }, [form.model, form.agentKind, form.targetSessionId, form.providerId, setField, providers, providersLoading, selectedAgentDeviceId]);++ }, [form.model, form.modelAgentKind, form.agentKind, form.targetSessionId, form.providerId, setField, providers, providersLoading, selectedAgentDeviceId]);++ // 绑定任务的显式模型属于任务所在电脑的目录。读到任务位置后让表单与之成对,之后切到+ // 「每次新建任务」时模型与运行位置仍然一致。+ useEffect(() => {- if (!isBound || !boundSessionReference || !form.model.trim()) return;++ if (!isBound || !boundSessionReference || !form.model.trim() || form.modelAgentDeviceId !== undefined) return;+ const location = boundSessionReference.agentDeviceId ?? '';+ if ((form.agentDeviceId ?? '') !== location) setField('agentDeviceId', location);- }, [isBound, boundSessionReference, form.model, form.agentDeviceId, setField]);++ }, [isBound, boundSessionReference, form.model, form.agentDeviceId, form.modelAgentDeviceId, setField]);useEffect(() => {- if (form.modelAgentKind || !currentModelEfforts || !form.effort) return;+ if (!modelCatalogReady || form.modelAgentKind || !currentModelEfforts || !form.effort) return;const allowed = currentModelEfforts as readonly string[];if (!allowed.includes(form.effort)) setField('effort', '');- }, [form.modelAgentKind, currentModelEfforts, form.effort, setField]);+ }, [modelCatalogReady, form.modelAgentKind, currentModelEfforts, form.effort, setField]);// Fast 模式门控:agent 级 hasFastMode × 该 (生效来源, 模型) 的 supportsFastMode(per-provider,// 唯一真相)。生效来源按 form.providerId 解析(空则该模型的默认来源)。Claude 当前 hasFastMode@@@ -1380,7 -1409,6 +1410,7 @@@onFollowSession={() => selectModelConfiguration(null,boundSessionReference?.agentKind === 'cc' ? 'claude-code' : boundSessionReference?.agentKind)}agentKind={form.agentKind}- agentDeviceId={form.modelAgentDeviceId}++ agentDeviceId={selectedAgentDeviceId ?? undefined}modelValue={form.model}onChangeModel={(v) => setField('model', v)}effortValue={form.effort}diff --cc apps/desktop/src/renderer/features/scheduler/components/__tests__/ScheduleChip.test.tsxindex 0aca2ec556,93b086383f..e94f29478d--- a/apps/desktop/src/renderer/features/scheduler/components/__tests__/ScheduleChip.test.tsx+++ b/apps/desktop/src/renderer/features/scheduler/components/__tests__/ScheduleChip.test.tsx@@@ -3,11 -3,14 +3,16 @@@ import { useState } from 'react'import { cleanup, fireEvent, render, screen } from '@testing-library/react';import { afterEach, expect, it, vi } from 'vitest';+ // The shared-quota rail observes auth; this component fixture has no auth host.+ vi.mock('@/contexts/AuthContext', () => ({ useOptionalAuthUser: () => null }));+vi.mock('react-i18next', () => ({useTranslation: () => ({ t: (key: string) => key, i18n: { language: 'en' } }),+ // ScheduleChips 经模型面板的远程位置候选间接加载 i18n 初始化。+ initReactI18next: { type: '3rdParty', init: () => undefined },}));+// These cases mount the timing chip only; device/auth state belongs to the model picker.+vi.mock('@/hooks/useModelRouteDevices', () => ({ useModelRouteDevices: () => ({ devices: undefined }) }));import { ScheduleChip } from '../ScheduleChips';diff --cc apps/desktop/src/renderer/features/scheduler/components/__tests__/ScheduleFormDialog.test.tsxindex 0000000000,c3d83ef188..1712a2f83dmode 000000,100644..100644--- a/apps/desktop/src/renderer/features/scheduler/components/__tests__/ScheduleFormDialog.test.tsx+++ b/apps/desktop/src/renderer/features/scheduler/components/__tests__/ScheduleFormDialog.test.tsx@@@ -1,0 -1,126 +1,146 @@@+ // @vitest-environment jsdom+ import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';+ import type { ReactNode } from 'react';+ import { afterEach, beforeEach, expect, it, vi } from 'vitest';-import type { Schedule } from '@cindy/maker-scheduler';++import type { Schedule, ScheduleTemplate } from '@cindy/maker-scheduler';++ // PR #6832: exercise the real form's save/effect path. Pure form-logic tests cannot+ // catch the dialog wiring a remote choice to the local catalog. Minimal inputs:+ // a remote-only model, or same-ID models with conflicting effort/Fast capabilities.+ // Tier: unit/jsdom; separate from hook-only tests because this renders the dialog.+ // Standalone Windows run: 3.14s Vitest / 4.21s process wall time (5 cases).+ const state = vi.hoisted(() => ({+ warning: vi.fn(),+ references: new Map<string, unknown>(),+ loading: false,+ localModels: [{ id: 'shared', efforts: ['low'], supportsFastMode: false }],+ remoteModels: [+ { id: 'shared', efforts: ['ultra'], supportsFastMode: true },+ { id: 'remote-only', efforts: ['ultra'], supportsFastMode: true },+ ],+ }));+ vi.mock('react-router-dom', () => ({ useNavigate: () => vi.fn() }));+ vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key }) }));+ vi.mock('@/lib/toast', () => ({ toast: { warning: state.warning, success: vi.fn(), error: vi.fn() } }));+ vi.mock('@/hooks/useAgentCapabilities', () => ({+ getCachedCapabilities: () => null,+ useAgentCapabilities: (_agent: string, device?: string) => ({+ capabilities: { availableModels: device && !state.loading ? state.remoteModels : state.localModels, hasFastMode: true },+ loading: !!device && state.loading,+ }),+ }));+ vi.mock('@/hooks/useProviders', () => ({+ useProviders: () => ({ providers: [{ id: 'source', connected: true, agents: ['codex'], routing: { codex: {} },+ models: { codex: state.localModels } }], loading: false }),+ }));+ vi.mock('@/hooks/useDeviceProviders', () => ({+ useDeviceProviders: () => ({ providers: [{ id: 'source', connected: true, agents: ['codex'], routing: { codex: {} },+ models: { codex: state.loading ? state.localModels : state.remoteModels } }], loading: state.loading }),+ }));+ vi.mock('@/hooks/useFeishuBot', () => ({ useFeishuBot: () => ({ status: 'disconnected' }) }));+ vi.mock('@/hooks/useWecomGroupNotificationSettings', () => ({ useWecomGroupNotificationSettings: () => ({}) }));+ vi.mock('@/hooks/useProjectPickerOptions', () => ({ useProjectPickerOptions: () => [] }));+ vi.mock('../../hooks/useSessionReferences', () => ({ useSessionReferences: () => state.references }));+ vi.mock('@radix-ui/react-dialog', () => {+ const Pass = ({ children }: { children?: ReactNode }) => <>{children}</>;+ return { Root: Pass, Portal: Pass, Overlay: () => null, Content: Pass, Title: Pass, Description: Pass, Close: Pass };+ });+ vi.mock('@/components/ui/tooltip', () => ({ Tip: ({ children }: { children?: ReactNode }) => children }));+ vi.mock('../TemplateGallery', () => ({ TemplateGallery: () => null }));+ vi.mock('../TemplateParamForm', () => ({ TemplateParamForm: () => null }));+ vi.mock('../BoundSessionCard', () => ({ BoundSessionCard: () => null }));+ vi.mock('../ScheduleChips', () => ({+ ProjectChip: () => null, ScheduleChip: () => null, ScheduleSettingsButton: () => null, ThreadPickerInline: () => null,+ ModelEffortChip: ({ onSelect }: { onSelect: (choice: unknown) => void }) => (+ <button onClick={() => onSelect({ engine: 'codex', modelId: 'remote-only', providerId: 'source',+ effort: 'ultra', fast: true, agentDevice: { deviceId: 'studio' } })}>select remote</button>+ ),+ }));++ import { ScheduleFormDialog } from '../ScheduleFormDialog';++ function schedule(patch: Partial<Schedule> = {}): Schedule {+ return { id: 'schedule', name: 'Test', prompt: 'Check work', agentKind: 'codex',+ model: 'shared', providerId: 'source', cronExpr: '0 9 * * *', timezone: 'UTC',+ recurring: true, manual: false, workspaceKind: 'dialogue', useWorktree: false,+ notify: { desktop: true, feishu: false }, status: 'active', kind: 'cron', source: 'user',+ jobType: 'prompt', createdAt: 1, updatedAt: 1, ...patch };+ }+ function mount(initial: Schedule) {+ const onSubmit = vi.fn(async () => {});+ const element = () => <ScheduleFormDialog open initial={initial} onOpenChange={() => {}} onSubmit={onSubmit} />;+ const view = render(element());+ return { onSubmit, refresh: () => view.rerender(element()),+ save: () => fireEvent.click(screen.getByRole('button', { name: 'scheduler.editor.promptDialog.saveAria' })) };+ }+ beforeEach(() => {+ vi.clearAllMocks();+ state.references.clear();+ state.loading = false;+ localStorage.clear();+ });+ afterEach(cleanup);++ it('saves a selected remote-only model against its own catalog', async () => {+ const form = mount(schedule());+ fireEvent.click(screen.getByText('select remote'));+ form.save();+ await waitFor(() => expect(form.onSubmit).toHaveBeenCalledWith(expect.objectContaining({- agentDeviceId: 'studio', model: 'remote-only', providerId: 'source', effort: 'ultra', fastMode: true,++ modelAgentDeviceId: 'studio', model: 'remote-only', providerId: 'source', effort: 'ultra', fastMode: true,+ }), true));+ });++ it('validates an override at the bound task location even without a saved device', async () => {+ state.references.set('bound', { id: 'bound', state: 'available', status: 'active', agentKind: 'codex', agentDeviceId: 'studio' });+ const form = mount(schedule({ targetSessionId: 'bound', model: 'remote-only', modelAgentKind: 'codex' }));+ form.save();+ await waitFor(() => expect(form.onSubmit).toHaveBeenCalledWith(expect.objectContaining({+ targetSessionId: 'bound', model: 'remote-only',+ }), true));+ });++ it('keeps legacy remote effort and Fast when the local same-ID copy differs', async () => {+ const form = mount(schedule({ agentDeviceId: 'studio', effort: 'ultra', fastMode: true }));+ form.save();+ await waitFor(() => expect(form.onSubmit).toHaveBeenCalledWith(expect.objectContaining({+ effort: 'ultra', fastMode: true,+ }), true));+ });++ it('rejects a model missing from the selected remote catalog', () => {+ const form = mount(schedule({ agentDeviceId: 'studio', model: 'removed', modelAgentKind: 'codex' }));+ form.save();+ expect(form.onSubmit).not.toHaveBeenCalled();+ expect(state.warning).toHaveBeenCalledWith('scheduler.editor.validation.modelUnavailable');+ });++ it('preserves remote preferences while its catalog refresh is still loading', async () => {+ state.loading = true;+ const form = mount(schedule({ agentDeviceId: 'studio', effort: 'ultra', fastMode: true }));+ state.loading = false;+ form.refresh();+ form.save();+ await waitFor(() => expect(form.onSubmit).toHaveBeenCalledWith(expect.objectContaining({+ effort: 'ultra', fastMode: true,+ }), true));+ });++++// Merge review, unit/jsdom: providers refresh with a new array while a template++// draft is open. The real initialization effect must not replay over user edits.++it('keeps edited template fields across catalog refreshes and reapplies on reopening', () => {++ const template: ScheduleTemplate = { id: 'initial', name: 'Template title', prompt: 'Template prompt',++ description: '', category: 'code-quality', source: 'builtin', agentKind: 'codex', model: 'shared', providerId: 'source' };++ const element = (open = true) => <ScheduleFormDialog open={open} initial={null} initialTemplate={template}++ onOpenChange={() => {}} onSubmit={async () => {}} />;++ const view = render(element());++ fireEvent.change(screen.getByDisplayValue('Template title'), { target: { value: 'Edited title' } });++ fireEvent.change(screen.getByDisplayValue('Template prompt'), { target: { value: 'Edited prompt' } });++ // The useProviders fixture returns a fresh catalog array on each render.++ view.rerender(element());++ expect(screen.getByDisplayValue('Edited title')).toBeTruthy();++ expect(screen.getByDisplayValue('Edited prompt')).toBeTruthy();++ view.rerender(element(false));++ view.rerender(element());++ expect(screen.getByDisplayValue('Template title')).toBeTruthy();++ expect(screen.getByDisplayValue('Template prompt')).toBeTruthy();++});diff --cc apps/desktop/src/renderer/features/scheduler/components/__tests__/ThreadPickerInline.test.tsxindex de8df2f541,52d96b7291..717601b53f--- a/apps/desktop/src/renderer/features/scheduler/components/__tests__/ThreadPickerInline.test.tsx+++ b/apps/desktop/src/renderer/features/scheduler/components/__tests__/ThreadPickerInline.test.tsx@@@ -16,10 -16,13 +16,15 @@@ const mocks = vi.hoisted(() => (}));vi.mock('@/lib/sessionService', () => ({ list: mocks.list }));+// These cases mount the task picker only; model location state is unrelated.+vi.mock('@/hooks/useModelRouteDevices', () => ({ useModelRouteDevices: () => ({ devices: undefined }) }));+ // The shared-quota rail observes auth; this component fixture has no auth host.+ vi.mock('@/contexts/AuthContext', () => ({ useOptionalAuthUser: () => null }));+vi.mock('react-i18next', () => ({useTranslation: () => ({ t: (key: string) => key }),+ // ScheduleChips 经模型面板的远程位置候选间接加载 i18n 初始化。+ initReactI18next: { type: '3rdParty', init: () => undefined },}));import { ThreadPickerInline } from '../ScheduleChips';diff --cc apps/desktop/src/renderer/features/scheduler/hooks/__tests__/useScheduleForm.validate.test.tsxindex f9ea9317f3,a063b97676..4b7f71ce3a--- a/apps/desktop/src/renderer/features/scheduler/hooks/__tests__/useScheduleForm.validate.test.tsx+++ b/apps/desktop/src/renderer/features/scheduler/hooks/__tests__/useScheduleForm.validate.test.tsx@@@ -3,6 -3,6 +3,7 @@@import { act, renderHook } from '@testing-library/react';import { describe, expect, it } from 'vitest';import type { Schedule, ScheduleTemplate } from '@cindy/maker-scheduler';++import type { ProviderView } from '@cindy/model-providers';import type { Session } from '@/lib/ccAgent.types';import { useScheduleForm } from '../useScheduleForm';@@@ -56,32 -56,6 +57,79 @@@ describe('saved automation model selectcategory: 'code-quality', source: 'builtin',};++ // Merge regression, unit/jsdom: opening and renaming a legacy persistent task++ // must retain its fresh-run default without pinning its existing task location.++ it('keeps legacy location semantics until the user explicitly changes the selection', () => {++ const saved = { id: 'legacy', name: 'Legacy', prompt: 'run', cronExpr: '0 * * * *',++ timezone: 'UTC', recurring: true, agentKind: 'codex', model: 'remote-model',++ providerId: 'remote-provider', agentDeviceId: 'studio', persistentSession: true,++ targetSessionId: 'bound-task', notify: { desktop: true, feishu: false } } as Schedule;++ const { result } = renderHook(() => useScheduleForm(saved));++ act(() => result.current.setField('name', 'Renamed'));++ expect(result.current.toInput()).toMatchObject({ name: 'Renamed', agentDeviceId: 'studio',++ modelAgentDeviceId: undefined, modelAgentKind: undefined });++ act(() => result.current.selectModelConfiguration(null));++ expect(result.current.toInput()).toMatchObject({ agentDeviceId: undefined,++ modelAgentDeviceId: undefined, model: undefined });++ });++++ // PR #6830 merge review, unit/jsdom: without matching local history a provider-only++ // template used to clear its local intent and leave the bound task on a share.++ it.each([true, false])('keeps a local template complete or blocks saving (catalog ready=%s)', (ready) => {++ const { result } = renderHook(() => useScheduleForm(null));++ act(() => {++ result.current.setField('name', 'Template');++ result.current.setField('prompt', 'Run');++ result.current.selectBoundSession({ id: 'remote-task', agentKind: 'codex' } as Session);++ });++ act(() => result.current.selectModelConfiguration({ agentKind: 'codex', model: 'remote-model',++ providerId: 'remote-provider', modelAgentDeviceId: 'shared:owner', effort: 'high', fastMode: false }));++ const providers = [{ id: 'template-local-provider', name: 'Local', source: 'user', connected: true,++ agents: ['codex'], models: { codex: [{ id: 'local-model', name: 'Local model' }] },++ routing: { codex: {} }, auth: { method: 'none' },++ }] as ProviderView[];++ act(() => result.current.applyTemplateAgentFields({ ...template, providerId: 'template-local-provider' },++ ready ? providers : undefined));++ expect(result.current.toInput()).toMatchObject({ targetSessionId: 'remote-task',++ modelAgentKind: 'codex', modelAgentDeviceId: '', providerId: 'template-local-provider',++ model: ready ? 'local-model' : undefined });++ expect(result.current.validate()).toEqual(ready ? null : {++ key: 'scheduler.editor.validation.modelUnavailable', values: { model: 'template-local-provider' },++ });++ });+++ // PR #6830: the hook used to reset location separately from the retained route.+ // Unit/jsdom: apply a same-Harness template to a shared choice, then serialize it.+ it('keeps the shared route when a template only repeats the current Harness', () => {+ const { result } = renderHook(() => useScheduleForm(null));+ const route = { agentKind: 'claude-code' as const, model: 'remote-model', providerId: 'remote-provider',+ modelAgentDeviceId: 'shared:owner', effort: 'high' as const, fastMode: true };+ act(() => result.current.selectModelConfiguration(route));+ act(() => result.current.applyTemplateAgentFields({ ...template, agentKind: route.agentKind }));+ expect(result.current.toInput()).toMatchObject({ modelAgentDeviceId: route.modelAgentDeviceId,+ agentKind: route.agentKind, model: route.model, providerId: route.providerId });+ });++ // A partial local template must not combine its model/provider with the old share.+ it.each([- { model: 'local-model' },- { providerId: 'local-provider' },- ])('discards inherited shared fields when applying a local route %j', (override) => {++ { override: { model: 'local-model' }, legacy: false },++ { override: { providerId: 'local-provider' }, legacy: false },++ { override: { model: 'local-model' }, legacy: true },++ { override: { providerId: 'local-provider' }, legacy: true },++ ])('discards inherited shared fields when applying a local route %j', ({ override, legacy }) => {+ const { result } = renderHook(() => useScheduleForm(null));+ act(() => result.current.selectModelConfiguration({ agentKind: 'claude-code', model: 'remote-model',+ providerId: 'remote-provider', modelAgentDeviceId: 'shared:owner', effort: 'high', fastMode: true }));++ if (legacy) act(() => {++ result.current.setField('modelAgentDeviceId', undefined);++ result.current.setField('agentDeviceId', 'studio');++ });+ act(() => result.current.applyTemplateAgentFields({ ...template, ...override }));+ expect(result.current.form).toMatchObject({ ...override, modelAgentDeviceId: '' });+ expect(result.current.form.model).not.toBe('remote-model');+ expect(result.current.form.providerId).not.toBe('remote-provider');+ });+it.each(['codex', 'pi'] as const)('saves the %s template Harness with its model after binding a task', (agentKind) => {const { result } = renderHook(() => useScheduleForm(null));act(() => result.current.selectBoundSession({ id: 'bound-codex', agentKind: 'codex' } as Session));diff --cc apps/desktop/src/renderer/features/scheduler/hooks/useScheduleForm.tsindex ac3f9b83a2,474ee99567..31f1c01214--- a/apps/desktop/src/renderer/features/scheduler/hooks/useScheduleForm.ts+++ b/apps/desktop/src/renderer/features/scheduler/hooks/useScheduleForm.ts@@@ -210,7 -211,8 +211,8 @@@ export function rememberScheduleFormPreworkspaceKind,workingDir: workspaceKind === 'project' ? form.workingDir : '',useWorktree: workspaceKind === 'project' && form.useWorktree,- lastByAgent: {+ // 另一台电脑上的选择属于那台的目录,不作为本机新建任务的默认记忆。- lastByAgent: form.agentDeviceId ? current.lastByAgent : {++ lastByAgent: (form.modelAgentDeviceId ?? form.agentDeviceId) ? current.lastByAgent : {...current.lastByAgent,[form.agentKind]: {model: form.model,@@@ -306,7 -308,7 +309,7 @@@ export interface UseScheduleFormResult*/selectBoundSession: (session: Session | null) => void;/** 应用模板里的 agent/model/provider/effort/fast 字段,并在跨 agent 时重建成目标 agent 的默认组合。 */-- applyTemplateAgentFields: (template: ScheduleTemplate) => void;++ applyTemplateAgentFields: (template: ScheduleTemplate, providers?: readonly ProviderView[]) => void;reset: (s?: Schedule | null, overrides?: Partial<ScheduleFormState>) => void;/*** 把表单转成 CreateScheduleInput;@@@ -352,8 -354,7 +355,8 @@@ export function useScheduleForm(initial? form.boundAgent.agentKind : form.agentKind);const boundAgent = followedAgentKind && form.targetSessionId? { sessionId: form.targetSessionId, agentKind } : form.boundAgent;- return { ...form, agentKind, boundAgent, model: '', providerId: '', effort: '', fastMode: false,- return { ...form, agentKind, boundAgent, model: '', providerId: '', agentDeviceId: '', effort: '', fastMode: false, modelAgentKind: undefined };++ return { ...form, agentKind, boundAgent, model: '', providerId: '', agentDeviceId: '', effort: '', fastMode: false,+ modelAgentKind: undefined, modelAgentDeviceId: undefined };});}, []);@@@ -366,15 -367,17 +369,18 @@@setForm(next);}, []);-- const applyTemplateAgentFields = useCallback((template: ScheduleTemplate) => {++ const applyTemplateAgentFields = useCallback((template: ScheduleTemplate, providers?: readonly ProviderView[]) => {setForm((f) => {const selection = resolveTemplateAgentFields(f, template, {getDefaultRoute: (agentKind, preferredProviderId) =>-- getScheduleDefaultRoute(agentKind, undefined, preferredProviderId),++ getScheduleDefaultRoute(agentKind, providers, preferredProviderId),getAgentPrefs: getScheduleAgentPrefs,});// A template that supplies a model is an explicit selection, even while following a bound task.- return { ...f, ...selection, modelAgentKind: selection.model.trim() ? selection.agentKind : undefined };+ // 模板的模型与来源属于本机目录;路由变了就回到本机运行。+ const sameRoute = selection.agentKind === f.agentKind && selection.model === f.model && selection.providerId === f.providerId;- return { ...f, ...selection, agentDeviceId: sameRoute ? f.agentDeviceId : '', modelAgentKind: selection.model.trim() ? selection.agentKind : undefined };++ return { ...f, ...selection, agentDeviceId: sameRoute ? f.agentDeviceId : '',++ modelAgentKind: selection.model.trim() || selection.modelAgentDeviceId === '' ? selection.agentKind : undefined };});}, []);@@@ -427,9 -430,9 +433,10 @@@boundAgent: { sessionId: session.id, agentKind: sessionAgentKindToScheduleAgentKind(session.agentKind) },model: '',modelAgentKind: undefined,+ modelAgentDeviceId: undefined,// 绑定会话 = 跟随其模型/来源,providerId 一并清空(与 model/effort 同语义)。providerId: '',+ agentDeviceId: '',effort: '',fastMode: false,};@@@ -443,6 -446,6 +450,9 @@@if ((form.executionMode ?? 'agent') === 'agent' && !form.prompt.trim()) {return { key: 'scheduler.editor.validation.promptRequired' };}++ if ((form.executionMode ?? 'agent') === 'agent' && form.modelAgentKind && !form.model.trim()) {++ return { key: 'scheduler.editor.validation.modelUnavailable', values: { model: form.providerId } };++ }if (form.executionMode === 'script' && !form.scriptCommand?.trim()) {return { key: 'scheduler.editor.validation.scriptCommandRequired' };}diff --cc apps/desktop/src/renderer/features/scheduler/lib/__tests__/scheduleFormLogic.test.tsindex 45f9dc7938,24f18b1962..8053d64934--- a/apps/desktop/src/renderer/features/scheduler/lib/__tests__/scheduleFormLogic.test.ts+++ b/apps/desktop/src/renderer/features/scheduler/lib/__tests__/scheduleFormLogic.test.ts@@@ -441,19 -441,6 +441,20 @@@ function makeTemplate(overrides: Partia}describe('buildScheduleInput — heartbeat 分支', () => {+ // Unit: the shared source is one selection across mode changes and persistence;+ // switching back to follow must clear the saved location together with the model.+ it('preserves the selected Agent location when changing run modes', () => {+ const form = makeForm({ targetSessionId: 'bound-task', modelAgentKind: 'pi',+ modelAgentDeviceId: 'shared:owner', model: 'remote-model', providerId: 'remote-provider' });+ const remembered = captureBinding(form);+ const fresh = applyRunMode(form, 'fresh', remembered);+ const bound = applyRunMode(fresh, 'bound', remembered);+ expect(buildScheduleInput(bound)).toMatchObject({ targetSessionId: 'bound-task',+ modelAgentDeviceId: 'shared:owner', model: 'remote-model', providerId: 'remote-provider' });- expect(buildScheduleInput({ ...bound, model: '' })).toHaveProperty('modelAgentDeviceId', undefined);++ // An incomplete explicit choice must reach validation whole, not become follow mode.++ expect(buildScheduleInput({ ...bound, model: '' })).toHaveProperty('modelAgentDeviceId', 'shared:owner');+ expect(buildScheduleInput({ ...fresh, modelAgentDeviceId: '' })).toHaveProperty('modelAgentDeviceId', '');+ });it('model/effort 空值时恒带 key 且值为 undefined(跟随会话 → patch 清列)', () => {const input = buildScheduleInput(makeForm({ targetSessionId: 'sess-1' }));expect(hasKey(input, 'model')).toBe(true);diff --cc apps/desktop/src/renderer/features/scheduler/lib/projectAutomationConfig.tsindex c203704adf,6237088ecb..0a4a5bf876--- a/apps/desktop/src/renderer/features/scheduler/lib/projectAutomationConfig.ts+++ b/apps/desktop/src/renderer/features/scheduler/lib/projectAutomationConfig.ts@@@ -62,9 -63,9 +64,10 @@@ export function scheduleToProjectConfigintervalMs: schedule.intervalMs,agentKind: schedule.agentKind,modelAgentKind: schedule.modelAgentKind,+ modelAgentDeviceId: schedule.modelAgentDeviceId,model: schedule.model,providerId: schedule.providerId || undefined,+ agentDeviceId: schedule.agentDeviceId,effort: schedule.effort,fastMode: schedule.fastMode,useWorktree: schedule.useWorktree,@@@ -93,9 -94,9 +96,10 @@@ export function formToProjectConfigintervalMs: form.intervalMs,agentKind: scheduleAgentKindForForm(form),modelAgentKind: form.model.trim() ? form.modelAgentKind : undefined,+ modelAgentDeviceId: form.model.trim() ? form.modelAgentDeviceId : undefined,model: form.model.trim() || undefined,providerId: form.providerId.trim() || undefined,+ agentDeviceId: form.model.trim() ? form.agentDeviceId?.trim() || undefined : undefined,effort: form.effort || undefined,// Codex / Pi 都生效(runner.ts:665);只认 codex 会丢弃 Pi 任务的 Fast(codex review)。fastMode: (form.agentKind === 'codex' || form.agentKind === 'pi') && form.fastMode ? true : undefined,diff --cc apps/desktop/src/renderer/features/scheduler/lib/scheduleFormLogic.tsindex a4575597bd,8ae0388bfe..6c6eb20096--- a/apps/desktop/src/renderer/features/scheduler/lib/scheduleFormLogic.ts+++ b/apps/desktop/src/renderer/features/scheduler/lib/scheduleFormLogic.ts@@@ -404,20 -408,16 +412,20 @@@ export function resolveTemplateAgentFieform: ScheduleFormState,template: Pick<ScheduleTemplate, 'agentKind' | 'model' | 'providerId' | 'effort' | 'fastMode'>,defaults: TemplateAgentDefaults,-): Pick<ScheduleFormState, 'agentKind' | 'model' | 'providerId' | 'effort' | 'fastMode'> {+): Pick<ScheduleFormState, 'agentKind' | 'model' | 'providerId' | 'effort' | 'fastMode' | 'modelAgentDeviceId'> {const agentKind = template.agentKind ?? form.agentKind;const agentChanged = agentKind !== form.agentKind;- const agentPrefs = agentChanged ? defaults.getAgentPrefs(agentKind) : null;const templateModel = typeof template.model === 'string' ? template.model.trim() : '';const templateProviderId = typeof template.providerId === 'string' ? template.providerId.trim() : undefined;+ const selectsLocalRoute = agentChanged || !!templateModel || templateProviderId !== undefined;+ // Retaining a route also retains its location. An explicit local template must+ // resolve missing fields from local defaults, never from the previous share.- const useLocalDefaults = agentChanged || (!!form.modelAgentDeviceId && selectsLocalRoute);++ const useLocalDefaults = agentChanged || (!!(form.modelAgentDeviceId ?? form.agentDeviceId) && selectsLocalRoute);+ const agentPrefs = useLocalDefaults ? defaults.getAgentPrefs(agentKind) : null;const templateEffort = template.effort && isEffortValue(template.effort) ? template.effort : undefined;- // 模板没给模型、换了 agent 时用默认路由:限定在模板 / 任务记忆的来源内,模型与来源整对应用。+ // 模板没给模型、切换引擎或回到本机时用本机默认路由,模型与来源整对应用。const defaultRoute =- agentChanged && !templateModel+ useLocalDefaults && !templateModel? defaults.getDefaultRoute(agentKind, templateProviderId ?? (agentPrefs?.providerId || null)): null;@@@ -574,8 -573,13 +582,14 @@@ export function buildScheduleInput(form// 相对间隔任务则原样保留权威值,不能从可能陈旧的 cronExpr 重新推导。intervalMs: form.intervalMs,agentKind: scheduleAgentKindForForm(form),-- modelAgentKind: !isScript && form.model.trim() ? form.modelAgentKind : undefined,- modelAgentDeviceId: !isScript && form.model.trim() ? form.modelAgentDeviceId : undefined,++ modelAgentKind: !isScript ? form.modelAgentKind : undefined,++ modelAgentDeviceId: !isScript && (form.model.trim() || form.modelAgentKind) ? form.modelAgentDeviceId : undefined,+ // 恒带 key:运行位置与模型 / 来源成对,update 时 undefined 清回本机。只有每次新建任务+ // (含持续会话首次与重建)才用它;绑定任务的运行位置跟随任务本身。+ agentDeviceId:+ !isScript && form.model.trim() && (!isHeartbeat || form.persistentSession)+ ? form.agentDeviceId?.trim() || undefined+ : undefined,workspaceKind: form.workspaceKind,useWorktree: !isScript && form.workspaceKind === 'project' && form.useWorktree,persistentSession: !isScript && form.persistentSession,@@@ -649,9 -640,9 +663,10 @@@ export function scheduleToUserCreateInpintervalMs: schedule.intervalMs,agentKind: schedule.modelAgentKind ?? schedule.agentKind,modelAgentKind: schedule.modelAgentKind,+ modelAgentDeviceId: schedule.modelAgentDeviceId,model: schedule.model,providerId: schedule.providerId,+ agentDeviceId: schedule.agentDeviceId,fastMode: schedule.fastMode,effort: schedule.effort,workspaceKind: schedule.workspaceKind,diff --cc docs/dev-rules/protocol-compatibility.mdindex ef73415262,8016f091a3..4c85cd390f--- a/docs/dev-rules/protocol-compatibility.md+++ b/docs/dev-rules/protocol-compatibility.md@@@ -3072,14 -3180,12 +3180,27 @@@ namespace + id 下同一插件的有�不改变已装批准、凭证、KV、版本或原生指纹。实现与时序验证见[原配置页协议](../remote-plugin-oauth.md#手机原配置页授权的增量能力)。+## 自动化的远程模型选择++`Schedule` / 创建与更新输入增量增加可选 `modelAgentDeviceId`:缺省保持旧版绑定任务的位置继承,+空字符串表示自动化所在电脑,非空使用既有远程/分享 Agent 标识。SQLite 新增可空文本列,+SQL NULL 对应缺省;项目 `version: 1` 配置同样允许该字段,旧文件无需改写。++既有 `agentDeviceId` 仍只提供新建/重建任务的默认位置;绑定任务存在时继续跟随它的当前位置。++显式 `modelAgentDeviceId` 优先于该默认值(包括空字符串本机),仅查看或修改旧记录的非模型字段++不会将默认位置转换为显式覆盖。MCP 的旧 `agentDeviceId: "local"` 仍沿用原协议;从++`schedule_list_models` 选择本机并填写 `modelAgentDeviceId` 时使用空字符串,不使用 `"local"`。+绑定任务或持续模式的 Agent 自动化显式选本机时也须有 `modelAgentKind` 与 `model`;不完整选择在保存前拒绝,+不把“选本机”误作继承绑定任务的位置。更新可沿用已存的完整选择,恢复跟随时清除显式选择。+`maker:get-capabilities` 返回 `supportsScheduleAgentDeviceSelection: true`。+新调用方只有明确看到此能力才向其它电脑提交位置选择;旧端未知字段会被忽略,禁止静默降级。+旧调用方修改新自动化的非模型字段仍保留位置;修改模型路线却未携带已固定的位置时拒绝保存,+避免意外把另一台电脑的供应商当作本机来源。执行与恢复仍使用既有远程授权、目录与切换协议。++ ## 伙伴关联项目++ `teammates` 增加 `settings:<botId>/projects` 与其项目详情资源。使用既有 list/form/toggle 原语,+ 保存仍绑定账号、控制端、伙伴和资源 revision。远程不传目录绝对路径,项目 ID 为不透明摘要;+ 旧控制端可忽略新入口,新控制端连接旧 Host 时不显示入口。手机两端与远程桌面共用宿主投影。+ 本机新增 `local-db:bots:projects:list/set` 仅用于受信 renderer,不进入远程 IPC allowlist。+ 旧 `workbench.json` 目录及设备归属沿用原格式;关联不进入任务负责范围或扩大文件权限。+ 不改服务端、数据库 schema、Mobile 原生配置或指纹。diff --cc docs/product-rules/agent-user-parity.mdindex e6821b7860,4708c2a0aa..12688ee856--- a/docs/product-rules/agent-user-parity.md+++ b/docs/product-rules/agent-user-parity.md@@@ -49,10 -49,11 +49,12 @@@| 任务 | 模型、推理强度、Fast | 有 | 无 || 任务 | 删除、Fork、Rewind、切换权限档、代用户确认权限或回答提问 | 无 | 无 || 协同 / Worker | 单个 / 批量创建、指定已有目录、查询实际目录与自有 worktree | 有 | 有(运行设备;新建 worktree 仅本机) |+ | 协同 / Worker | Lead 使用远程供应商时派发跨设备 Worker;独立选择工作电脑与模型电脑 | 有 | 有(`execution_device_id` + `agent_device_id`;目录查询支持同一工作电脑范围) || 协同 / Worker | 为 Worker 新建 worktree、指定源分支、归档时回收 | 有 | 无 || 定时任务 | 列出、详情、运行记录、修改、暂停、恢复、删除、立即运行 | 有 | 有(2026-10-14) |- | 定时任务 | 新建、安装检查脚本 | 有 | 无 |+| 定时任务 | 选择远程/分享供应商模型(运行位置、引擎、模型与速度);绑定任务或持续模式切回本机须保留完整引擎/模型选择 | 有 | 有(目标电脑须支持 `supportsScheduleAgentDeviceSelection`) |+ | 定时任务 | 新建、安装检查脚本 | 有(绑定远程 Agent 时由本机辅助模型生成脚本) | 无 |+ | 定时任务 | 查可选运行位置与模型;设每次新建任务的 Agent 运行位置(其他电脑 / 分享来的供应商) | 有(2026-10-22) | 无 || 定时任务 | 删除单条运行记录、标记已读 | 无 | 无 || 项目 | 列出、登记、改名、移除;工作目录列表 | 有 | 无 || 伙伴 | 发现伙伴、伙伴间消息 | 有 | 有 |diff --cc docs/product-rules/model-selector-unified.mdindex 3800800739,78f4ac32ff..b03bcafade--- a/docs/product-rules/model-selector-unified.md+++ b/docs/product-rules/model-selector-unified.md@@@ -209,19 -209,6 +209,19 @@@项目自动化的 `schedules.json` 同样保存可选的 `modelAgentKind`,导出、加载与配置同步均保留该标记;删除标记时清除数据库中的覆盖,已有绑定任务不丢失。旧版 `version: 1` 文件无需补字段。自动触发前按实际来源、Harness 和模型的当前目录拷贝补齐或收敛 effort,并清除已不受支持的 Fast;仍有效的用户选择保持不变。+自动化复用统一选择器的远程电脑与分享供应商列表、来源标识及图标。可选 `modelAgentDeviceId`- 保存所选 Agent 位置:缺省沿用绑定任务(新建时为本机),空字符串明确选择自动化所在电脑,++保存所选 Agent 位置:缺省沿用绑定任务;首次新建或重建时沿用 `agentDeviceId` 默认位置,未配置才用本机。空字符串明确选择自动化所在电脑,+非空为既有远程/分享来源 id。只修改后续触发的配置,不改历史记录、不打断当前运行;- 新建、持续与绑定模式保持不变。绑定任务执行后的恢复记录同时保存原 Agent 位置。++新建、持续与绑定模式保持不变。恢复记录同时保存原 Agent 位置,下次用户输入时恢复;自动化完成时不重建原生上下文。+工作目录、文件、Skill 与插件仍走自动化所在电脑的既有远程 Agent 通道与权限,不借用分享方配置。+Desktop 的 `ModelRouteSelector` 提供完整控件,`ModelRouteSelectorContent` 提供嵌入既有弹层的面板;+两者共用位置候选接入。自动化使用后者,保留自身按钮、跟随选项与保存时机,不另行拼装远程来源。+两种形式均透传统一选择器的完整选模结果;专用能力限制仍由调用场景声明。- 前置检查脚本的 AI 生成使用直接 utility HTTP 接口,暂不支持远程来源,明确返回不支持的传输方式;- 不得误用本机同名供应商。已有脚本的执行不受影响。++前置检查脚本的 AI 生成使用直接 utility HTTP 接口。表单选择远程来源时沿用本机辅助模型兜底;++直接向该接口传远程来源仍明确拒绝,不得误用本机同名供应商。已有脚本的执行不受影响。+“仅运行脚本”模式暂不支持远程模型来源;切换保存时保留完整来源并明确拒绝,原配置不变,+先选回本机模型后可切换。脚本的 `sessions.dispatch` 新建任务同样不得将远程配置解释成本机来源。+---## 4. 特殊情况检查表(实现与 review 逐条过)diff --cc packages/lizi-mcps/src/cindy_schedulerMcpServer.tsindex 261f142bcc,883964ac39..481db307d6--- a/packages/lizi-mcps/src/cindy_schedulerMcpServer.ts+++ b/packages/lizi-mcps/src/cindy_schedulerMcpServer.ts@@@ -89,7 -90,7 +90,7 @@@ const CATEGORY_ENUM = ['scheduler'] as/** 类目概览的一句话用途 + 作用范围(本机 / 可跨电脑);改工具作用范围时同步改这里。 */export const SCHEDULER_CATEGORY_DESCRIPTIONS: Record<(typeof CATEGORY_ENUM)[number], string> = {scheduler:- '定时任务(自动化 / 心跳)的查询与管理,模型可选本机、远程或分享供应商。定时任务保存在各自的电脑上:查询、修改、暂停、恢复、删除、立即运行可指定电脑(device,查询可传 all);新建、检查脚本安装、当前运行的通知设置只在本机。',- '定时任务(自动化 / 心跳)的查询与管理。定时任务保存在各自的电脑上:查询、修改、暂停、恢复、删除、立即运行可指定电脑(device,查询可传 all);新建、检查脚本安装、当前运行的通知设置只在本机。本机定时任务可指定每次新建任务时 Agent 在哪台电脑或分享来的供应商上运行(schedule_list_models 查位置与模型)。',++ '定时任务(自动化 / 心跳)的查询与管理。定时任务保存在各自的电脑上:查询、修改、暂停、恢复、删除、立即运行可指定电脑(device,查询可传 all);新建、检查脚本安装、当前运行的通知设置只在本机。本机定时任务可完整选择本机、远程或分享来源的模型(schedule_list_models 查位置与模型),并为自动化显式指定模型运行位置。',};function registerListToolsEntry(diff --cc packages/lizi-mcps/src/scheduler/create.tsindex e1fd351c55,dfaca11c9c..716861264b--- a/packages/lizi-mcps/src/scheduler/create.ts+++ b/packages/lizi-mcps/src/scheduler/create.ts@@@ -90,9 -91,6 +91,9 @@@ export function registerScheduleCreateT.boolean().describe('true=循环触发;false=触发一次后置 expired'),agentKind: z.enum(AGENT_KIND).describe('claude-code / codex / pi'),+ modelAgentKind: z.enum(AGENT_KIND).optional().describe('显式模型选择的引擎;绑定任务仅在下次执行时临时切换,结束后恢复'),+ fastMode: z.union([z.boolean(), z.literal('ultrafast')]).optional().describe('模型速度:false 标准、true 快速、ultrafast 超快;按所选模型支持的档位执行'),- modelAgentDeviceId: z.string().optional().describe('模型运行位置:远程或分享供应商的 agentDeviceId;空字符串=自动化所在电脑,省略=沿用绑定任务。远程选择须同时传 modelAgentKind、model、providerId;绑定任务或持续模式显式选择本机也须传 modelAgentKind 和 model;工作目录和工具仍属于自动化所在电脑'),++ modelAgentDeviceId: z.string().optional().describe('模型运行位置:远程或分享供应商的 agentDeviceId;空字符串=自动化所在电脑(schedule_list_models 的 local 在此须转为空字符串),省略=沿用绑定任务,首次新建则用 agentDeviceId 默认位置。远程选择须同时传 modelAgentKind、model、providerId;绑定任务或持续模式显式选择本机也须传 modelAgentKind 和 model;工作目录和工具仍属于自动化所在电脑'),kind: z.literal('cron').default('cron')diff --cc packages/lizi-mcps/src/scheduler/update.tsindex 786567e162,6412dcfe97..ae44f0ffa7--- a/packages/lizi-mcps/src/scheduler/update.ts+++ b/packages/lizi-mcps/src/scheduler/update.ts@@@ -40,9 -41,6 +41,9 @@@ export function registerScheduleUpdateTtimezone: z.string().min(1).optional(),recurring: z.boolean().optional(),agentKind: z.enum(AGENT_KIND).optional(),+ modelAgentKind: z.enum(AGENT_KIND).nullable().optional().describe('显式模型选择的引擎;null 清除覆盖'),+ fastMode: z.union([z.boolean(), z.literal('ultrafast')]).optional().describe('模型速度:false 标准、true 快速、ultrafast 超快;省略不修改'),- modelAgentDeviceId: z.string().nullable().optional().describe('模型运行位置:远程或分享供应商的 agentDeviceId;空字符串=自动化所在电脑,null=恢复沿用绑定任务,省略=不修改。远程选择须同时指定 modelAgentKind、model、providerId;绑定任务或持续模式切回本机也须有 modelAgentKind 和 model,可沿用已保存的完整选择'),++ modelAgentDeviceId: z.string().nullable().optional().describe('模型运行位置:远程或分享供应商的 agentDeviceId;空字符串=自动化所在电脑(schedule_list_models 的 local 在此须转为空字符串),null=恢复沿用绑定任务及首次新建的 agentDeviceId 默认位置,省略=不修改。远程选择须同时指定 modelAgentKind、model、providerId;绑定任务或持续模式切回本机也须有 modelAgentKind 和 model,可沿用已保存的完整选择'),kind: z.literal('cron').optional(),model: z.string()@@@ -187,7 -193,11 +196,11 @@@// undefined(storage 按 hasOwnProperty 判定 → 清列 NULL)。此前 schema 只收// string,agent 想把任务从一个引擎的模型路由上摘下来(如伙伴接管期用 Codex// 模型跑过、再改回 Claude Code)只能报 INVALID_ARGS,陈旧路由永远清不掉。+ const agentDeviceId = (patch as { agentDeviceId?: string | null }).agentDeviceId;+ if (agentDeviceId === null || agentDeviceId === LOCAL_SCHEDULE_AGENT_DEVICE) {+ input = { ...input, agentDeviceId: undefined };+ }- for (const key of ['model', 'providerId', 'effort', 'workingDir'] as const) {+ for (const key of ['model', 'providerId', 'effort', 'workingDir', 'modelAgentKind', 'modelAgentDeviceId'] as const) {if ((patch as Record<string, unknown>)[key] === null) {input = { ...input, [key]: undefined };}diff --cc packages/maker-scheduler/src/__tests__/scheduler.test.tsindex 883227c254,e6ceac13b3..05c1feb17c--- a/packages/maker-scheduler/src/__tests__/scheduler.test.ts+++ b/packages/maker-scheduler/src/__tests__/scheduler.test.ts@@@ -225,89 -225,6 +225,91 @@@ describe('Scheduler', () =>await expect(h.scheduler.create({ ...baseInput, modelAgentKind: 'pi', model: '' })).rejects.toThrow(/Harness/);});+ // Unit: old-client prompt edits preserve remote routing, but incomplete model+ // edits cannot silently keep a different device's credentials.+ it('preserves a saved shared route on partial edits and validates complete changes', async () => {+ const saved = await h.scheduler.create({ ...baseInput, modelAgentKind: 'pi',+ modelAgentDeviceId: 'shared:owner', providerId: 'shared-provider', model: 'remote-model' });+ expect((await h.scheduler.update(saved.id, { prompt: 'new prompt' })).modelAgentDeviceId).toBe('shared:owner');+ await expect(h.scheduler.update(saved.id, { model: 'other-model' })).rejects.toThrow('newer client');++ // Main's older location field cannot silently edit a pinned override.++ await expect(h.scheduler.update(saved.id, { agentDeviceId: 'studio' })).rejects.toThrow('newer client');+ expect((await h.scheduler.get(saved.id))?.model).toBe('remote-model');+ expect((await h.scheduler.update(saved.id, { modelAgentDeviceId: '', model: 'local-model' })).modelAgentDeviceId).toBe('');+ await expect(h.scheduler.create({ ...baseInput, modelAgentDeviceId: 'shared:owner' })).rejects.toThrow('remote model selection');+ });++ // Unit, PR #6830 review: a legacy bound automation has no explicit Harness.+ // A location-only local patch used to save successfully but still run remotely.+ it('rejects an incomplete local selection on a bound automation without changing its saved route', async () => {+ const legacy = { ...baseInput, agentKind: 'codex' as const, targetSessionId: 'remote-task', model: 'same-model', providerId: 'openai' };+ const saved = await h.scheduler.create(legacy);+ await expect(h.scheduler.update(saved.id, { modelAgentDeviceId: '' })).rejects.toThrow('bound task');+ expect(await h.scheduler.get(saved.id)).toEqual(saved);+ await expect(h.scheduler.create({ ...legacy, modelAgentDeviceId: '' })).rejects.toThrow('bound task');+ expect(await h.scheduler.update(saved.id, { modelAgentDeviceId: '', modelAgentKind: 'codex' }))+ .toMatchObject({ modelAgentDeviceId: '', modelAgentKind: 'codex', model: 'same-model' });+ const followed = await h.scheduler.update(saved.id, {+ modelAgentDeviceId: undefined, modelAgentKind: undefined, model: undefined, providerId: undefined,+ });+ expect(followed.modelAgentDeviceId).toBeUndefined();+ expect(followed.modelAgentKind).toBeUndefined();+ });++ // Unit: persistent schedules become bound after their first run. Accepting an+ // incomplete local selection must not make that required internal update fail.+ it('requires an executable local selection before a persistent automation first binds', async () => {+ const persistent = { ...baseInput, persistentSession: true, modelAgentDeviceId: '', model: 'local-model' };+ await expect(h.scheduler.create(persistent)).rejects.toThrow('bound task');+ const saved = await h.scheduler.create({ ...persistent, modelAgentKind: 'codex' });+ expect(await h.scheduler.update(saved.id, { targetSessionId: 'first-run-task' }))+ .toMatchObject({ targetSessionId: 'first-run-task', modelAgentDeviceId: '', modelAgentKind: 'codex' });+ });++ // Unit (model-selector-unified.md §3): update/runNow must preserve an active+ // run and history while later runs use the saved route. The former one-way+ // case missed same-model/provider remote -> local -> remote -> local changes,+ // including clearing effort/Fast; no real timers or vendor calls are needed.+ it('applies repeated location changes only to later runs', async () => {+ let finish!: (value: FireResult) => void;+ let entered!: () => void;+ const started = new Promise<void>((resolve) => { entered = resolve; });+ const calls: Schedule[] = [];+ const local = makeHarness({ runnerImpl: async (schedule) => {+ calls.push(schedule);+ if (calls.length > 1) return { sessionId: `task-${calls.length}` };+ entered();+ return new Promise<FireResult>((resolve) => { finish = resolve; });+ } });+ const saved = await local.scheduler.create({ ...baseInput, model: 'original' });+ const run = local.scheduler.runNow(saved.id);+ await started;+ const remote = { modelAgentKind: 'codex' as const, modelAgentDeviceId: 'shared:owner',+ model: 'same-model', providerId: 'same-provider', effort: 'xhigh' as const, fastMode: 'ultrafast' as const };+ const onHost = { ...remote, modelAgentDeviceId: '', effort: undefined, fastMode: false };+ await local.scheduler.update(saved.id, remote);+ expect(calls[0]).toMatchObject({ model: 'original' });+ expect(calls[0].modelAgentDeviceId).toBeUndefined();+ finish({ sessionId: 'original-task' });+ await run;+ await local.scheduler.runNow(saved.id);+ expect(calls[1]).toMatchObject(remote);+ const firstHistory = await local.scheduler.listRuns(saved.id, 10);+ for (const route of [onHost, remote, onHost]) {+ expect(await local.scheduler.update(saved.id, route)).toMatchObject(route);+ await local.scheduler.runNow(saved.id);+ expect(calls.at(-1)).toMatchObject(route);+ }+ expect(calls[0]).toMatchObject({ model: 'original' });+ expect(calls[0].modelAgentDeviceId).toBeUndefined();+ expect(calls[1]).toMatchObject(remote);+ for (const previous of firstHistory) {+ expect((await local.scheduler.listRuns(saved.id, 10)).find((r) => r.id === previous.id)).toEqual(previous);+ }+ expect((await local.scheduler.listRuns(saved.id, 10)).map((r) => r.sessionId).sort())+ .toEqual(['original-task', 'task-2', 'task-3', 'task-4', 'task-5']);+ });+it('create() computes nextFireAt and adds to active map', async () => {const sch = await h.scheduler.create({ ...baseInput });// From 00:00:30, next minute boundary = 00:01:00@@@ -661,24 -602,6 +687,24 @@@).rejects.toThrow('prompt is required for agent execution mode');});+ // Review regression (unit): script sessions.dispatch only resolves local+ // defaults. Reject remote routes before persistence instead of charging a+ // same-id local provider; prior shape tests did not cover a remote selection.+ it('rejects remote model routes in scripts and preserves the saved automation', async () => {+ const remote = { modelAgentKind: 'codex' as const, modelAgentDeviceId: 'shared:owner',+ model: 'same-model', providerId: 'openai' };+ const script = { executionMode: 'script' as const, workspaceKind: 'project' as const,+ workingDir: '/repo', scriptConfig: { command: 'node run.mjs', capabilities: ['sessions.dispatch' as const] } };+ await expect(h.scheduler.create({ ...baseInput, ...remote, ...script })).rejects.toThrow('script execution does not support remote model sources');- const saved = await h.scheduler.create({ ...baseInput, ...remote });++ const saved = await h.scheduler.create({ ...baseInput, ...remote, agentDeviceId: 'legacy-studio' });+ await expect(h.scheduler.update(saved.id, script)).rejects.toThrow('script execution does not support remote model sources');+ expect(await h.scheduler.get(saved.id)).toEqual(saved);+ // The explicit local choice remains supported; no new gate on local scripts.+ expect(await h.scheduler.update(saved.id, { ...script, modelAgentDeviceId: '' })).toMatchObject({+ ...script, ...remote, modelAgentDeviceId: '',+ });+ });+it('recurring fire updates lastFiredAt and recomputes nextFireAt', async () => {const sch = await h.scheduler.create({ ...baseInput });h.clock.setTo(Date.UTC(2026, 0, 1, 0, 1, 5));diff --cc packages/maker-scheduler/src/engine/scheduler.tsindex 76665bac4e,89868083bb..7a848c357d--- a/packages/maker-scheduler/src/engine/scheduler.ts+++ b/packages/maker-scheduler/src/engine/scheduler.ts@@@ -56,26 -56,27 +56,39 @@@ function normalizeScriptConfig}function validateScheduleExecutionShape(- schedule: Pick<Schedule, 'executionMode' | 'scriptConfig' | 'workspaceKind' | 'workingDir' | 'useWorktree' | 'targetSessionId' | 'persistentSession' | 'prompt' | 'silentWhenIdle' | 'modelAgentKind' | 'modelAgentDeviceId' | 'model' | 'providerId'>,- schedule: Pick<Schedule, 'executionMode' | 'scriptConfig' | 'workspaceKind' | 'workingDir' | 'useWorktree' | 'targetSessionId' | 'persistentSession' | 'prompt' | 'silentWhenIdle' | 'modelAgentKind' | 'model' | 'agentDeviceId'>,++ schedule: Pick<Schedule, 'executionMode' | 'scriptConfig' | 'workspaceKind' | 'workingDir' | 'useWorktree' | 'targetSessionId' | 'persistentSession' | 'prompt' | 'silentWhenIdle' | 'modelAgentKind' | 'modelAgentDeviceId' | 'agentDeviceId' | 'model' | 'providerId'>,opts: { checkAgentPrompt: boolean } = { checkAgentPrompt: true },): void {+ // A bound agent run only overrides its task's location with an explicit model+ // selection. Reject a local-only patch instead of silently inheriting remote.+ if (schedule.modelAgentDeviceId === '' && (schedule.targetSessionId || schedule.persistentSession) &&+ (schedule.executionMode ?? 'agent') === 'agent' &&+ (!schedule.modelAgentKind || !schedule.model?.trim())) {+ throw new Error('Explicit scheduled Agent location for a bound task requires a Harness and model');+ }+ if (schedule.modelAgentDeviceId !== undefined && (+ typeof schedule.modelAgentDeviceId !== 'string' ||+ (schedule.modelAgentDeviceId !== '' && (!schedule.modelAgentDeviceId.trim() ||+ !schedule.modelAgentKind || !schedule.model?.trim() || !schedule.providerId?.trim()))+ )) throw new Error('Scheduled remote model selection requires a device, Harness, model and provider');if (schedule.modelAgentKind != null) {if (!['claude-code', 'codex', 'pi'].includes(schedule.modelAgentKind) || !schedule.model?.trim()) {throw new Error('Explicit scheduled model Harness requires a supported Harness and model');}}+ if (schedule.agentDeviceId !== undefined) {+ // 运行位置只配显式模型:那台电脑的默认模型无法在本机解析。+ // 与创建任务时 agentDeviceId 的校验同一口径。+ if (typeof schedule.agentDeviceId !== 'string' || !/^[A-Za-z0-9_.:-]{1,128}$/.test(schedule.agentDeviceId)) {+ throw new Error('agentDeviceId must be a valid device id');+ }- if ((schedule.executionMode ?? 'agent') === 'script') {++ if (schedule.modelAgentDeviceId === undefined && (schedule.executionMode ?? 'agent') === 'script') {+ throw new Error('script execution does not support agentDeviceId');+ }- if (!schedule.model?.trim()) {++ if (schedule.modelAgentDeviceId === undefined && !schedule.model?.trim()) {+ throw new Error('agentDeviceId requires an explicit model');+ }+ }if ((schedule.executionMode ?? 'agent') !== 'script') {// 堵 update 逃逸:script 任务(prompt 合法为空)经 patch 只切 executionMode='agent'// 时,若不校验会落库空提示词的 agent 任务,触发即烧一轮空输入。checkAgentPrompt@@@ -1399,13 -1398,6 +1413,13 @@@ export class Scheduler extends EventEmi}const existing = await this.get(id);if (!existing) throw new Error(`Schedule not found: ${id}`);+ // Old clients can rename an automation without losing its route. A model edit,+ // however, must carry the location once one has been explicitly selected.+ if (existing.modelAgentDeviceId !== undefined && patch.modelAgentDeviceId === undefined &&+ !Object.prototype.hasOwnProperty.call(patch, 'modelAgentDeviceId') &&- (['agentKind', 'modelAgentKind', 'model', 'providerId'] as const).some(++ (['agentKind', 'modelAgentKind', 'model', 'providerId', 'agentDeviceId'] as const).some(+ (key) => Object.prototype.hasOwnProperty.call(patch, key) && patch[key] !== existing[key],+ )) throw new Error('Editing this scheduled model route requires a newer client');// Agent-only quiet reporting does not apply when changing to script mode.// Keep explicit invalid combinations subject to the existing validation.if (patch.executionMode === 'script' && existing.executionMode !== 'script'diff --cc packages/maker-shared/src/scheduleTypes.tsindex 05c27193ce,7f99b67841..c4c97d3f0b--- a/packages/maker-shared/src/scheduleTypes.ts+++ b/packages/maker-shared/src/scheduleTypes.ts@@@ -31,10 -31,13 +31,15 @@@ export interface RemoteScheduleWriteInpintervalMs?: number | null;agentKind: RemoteScheduleAgentKind;modelAgentKind?: RemoteScheduleAgentKind;+ /** Absent = inherit bound task; empty string = automation host. */+ modelAgentDeviceId?: string;model?: string;providerId?: string;+ /**+ * Agent 运行位置(相对任务所在电脑的另一台电脑);null = 任务所在电脑。省略时若本次+ * 改了模型或来源,host 把运行位置归回任务所在电脑(来源与位置成对),否则保留原值。+ */+ agentDeviceId?: string | null;effort?: string;fastMode?: boolean | 'ultrafast';workspaceKind?: RemoteScheduleWorkspaceKind;@@@ -105,10 -108,10 +110,12 @@@ export interface RemoteScheduleintervalMs?: number;agentKind?: RemoteScheduleAgentKind;modelAgentKind?: RemoteScheduleAgentKind;+ /** Absent = inherit bound task; empty string = automation host. */+ modelAgentDeviceId?: string;model?: string;providerId?: string;+ /** Agent 运行位置;省略 = 任务所在电脑。 */+ agentDeviceId?: string;effort?: string;fastMode?: boolean | 'ultrafast';workspaceKind?: RemoteScheduleWorkspaceKind;