Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(scheduler): support remote and shared model selection
Yuewei-LL329424ab3efc
diff --git a/apps/desktop/drizzle/0130_ambitious_hellfire_club.sql b/apps/desktop/drizzle/0130_ambitious_hellfire_club.sqlnew file mode 100644index 0000000000..e0ac49d1ec--- /dev/null+++ b/apps/desktop/drizzle/0130_ambitious_hellfire_club.sql@@ -0,0 +1 @@+SELECT 1;diff --git a/apps/desktop/drizzle/meta/0130_snapshot.json b/apps/desktop/drizzle/meta/0130_snapshot.jsonnew file mode 100644index 0000000000..1114dcc04f--- /dev/null+++ b/apps/desktop/drizzle/meta/0130_snapshot.json@@ -0,0 +1,7215 @@+{+ "version": "6",+ "dialect": "sqlite",+ "id": "a34bb774-dc04-4a11-b70c-f87f457d109e",+ "prevId": "4080b7b1-04ec-45f5-833c-cc80efbbf146",+ "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+ },+ "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+ }+ }+ }+ }+ }+}\ No newline at end of filediff --git a/apps/desktop/drizzle/meta/_journal.json b/apps/desktop/drizzle/meta/_journal.jsonindex 58d8984a1f..86cfa885b8 100644--- a/apps/desktop/drizzle/meta/_journal.json+++ b/apps/desktop/drizzle/meta/_journal.json@@ -911,6 +911,13 @@"when": 1792496800812,"tag": "0129_chemical_thor","breakpoints": true+ },+ {+ "idx": 130,+ "version": "6",+ "when": 1792659817002,+ "tag": "0130_ambitious_hellfire_club",+ "breakpoints": true}]}\ No newline at end of filediff --git a/apps/desktop/drizzle/scripts/0130_ambitious_hellfire_club.ts b/apps/desktop/drizzle/scripts/0130_ambitious_hellfire_club.tsnew file mode 100644index 0000000000..e20c250639--- /dev/null+++ b/apps/desktop/drizzle/scripts/0130_ambitious_hellfire_club.ts@@ -0,0 +1,12 @@+import type Database from 'better-sqlite3';++function run(db: Database.Database): void {+ const table = db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'schedules'").get();+ if (!table) return;+ const columns = db.prepare('PRAGMA table_info(schedules)').all() as Array<{ name: string }>;+ if (!columns.some((column) => column.name === 'model_agent_device_id')) {+ db.exec('ALTER TABLE schedules ADD model_agent_device_id TEXT');+ }+}++module.exports = { run };diff --git a/apps/desktop/scripts/fixtures/scheduler-model/scheduler-model-fixture.tsx b/apps/desktop/scripts/fixtures/scheduler-model/scheduler-model-fixture.tsxnew file mode 100644index 0000000000..1dff25e6b0--- /dev/null+++ b/apps/desktop/scripts/fixtures/scheduler-model/scheduler-model-fixture.tsx@@ -0,0 +1,28 @@+import { useState } from 'react';+import { mountPage, subscription } from '../../ui-page/harness';+import { ModelEffortChip } from '../../../src/renderer/features/scheduler/components/ScheduleChips';++function Fixture() {+ const [device, setDevice] = useState('');+ const [provider, setProvider] = useState('anthropic');+ return <main className="flex justify-end p-6">+ <div data-testid="automation-model" data-device={device} data-provider={provider}>+ <ModelEffortChip agentKind="claude-code" agentDeviceId={device}+ modelValue="claude-sonnet-4-6" providerId={provider} effortValue="high"+ onSelect={selection => { setDevice(selection.agentDevice?.deviceId ?? ''); setProvider(selection.providerId); }}+ onChangeProviderId={setProvider} onChangeModel={() => {}} onChangeEffort={() => {}} onFollowSession={() => {}} />+ </div>+ </main>;+}++void mountPage({+ host: { maker: {+ requestProviderModelsAutoRefresh: async () => undefined,+ onProvidersChanged: subscription('providersChanged'),+ getModelContextLimit: async () => ({ limit: 200000, isCustomized: false }),+ }, safeStorageRead: async () => null,+ deviceLink: { invoke: async () => null, onRemotePush: subscription('remotePush'),+ onStatusChanged: subscription('remoteStatus'), onPresenceChanged: subscription('presence') },+ },+ render: () => <Fixture />,+});diff --git a/apps/desktop/scripts/fixtures/scheduler-model/ui-page.mjs b/apps/desktop/scripts/fixtures/scheduler-model/ui-page.mjsnew file mode 100644index 0000000000..5149723249--- /dev/null+++ b/apps/desktop/scripts/fixtures/scheduler-model/ui-page.mjs@@ -0,0 +1,45 @@+import assert from 'node:assert/strict';++const model = { id: 'claude-sonnet-4-6', name: 'Claude Sonnet 4.6', contextWindow: 200000,+ efforts: ['low', 'medium', 'high'], defaultEffort: 'high', icon: 'claude' };+const provider = { id: 'anthropic', name: 'Anthropic', connected: true, remoteInvocationEnabled: true,+ agents: ['claude-code'], source: 'builtin', auth: { method: 'oauth' },+ routing: { 'claude-code': { mode: 'direct', wireProtocol: 'anthropic-messages' } },+ models: { 'claude-code': [model] } };+const snapshot = JSON.stringify({ providers: [provider], providerOrder: [], loading: false, error: null, unsupported: false });+const caps = JSON.stringify({ availableModels: [{ ...model, displayName: model.name }],+ effortLevels: model.efforts.map(id => ({ id, displayName: id })) });++export default {+ name: 'scheduler-model',+ entry: './scheduler-model-fixture.tsx',+ viewport: { width: 720, height: 600 },+ real: 'Automation ModelEffortChip, unified model picker, selection callback, source icons, themes and translations',+ notCovered: 'Live device/share discovery, authorization, persistence and task execution; catalog hooks use fixture snapshots',+ stubs: {+ 'src/renderer/hooks/useModelRouteDevices': `const devices = [{ deviceId: 'shared:fixture', name: 'Shared Anthropic' }]; export const useModelRouteDevices = () => ({ devices });`,+ 'src/renderer/hooks/useProviders': { partial: `const snapshot = ${snapshot}; export const useProviders = () => snapshot;` },+ 'src/renderer/hooks/useDeviceProviders': { partial: `const snapshot = ${snapshot}; export const useDeviceProviders = () => snapshot;` },+ 'src/renderer/hooks/useDevicesProviders': { partial: `const snapshot = ${snapshot}; const devices = new Map([['shared:fixture', snapshot]]); export const useDevicesProviders = () => devices;` },+ 'src/renderer/hooks/useAgentCapabilities': { partial: `const capabilities = ${caps}; export const useAgentCapabilities = () => ({ capabilities, loading: false, error: null });` },+ 'src/renderer/hooks/useAvailableAgents': { partial: `const agents = ['claude-code']; export const useModelPickerAgents = () => agents;` },+ },+ cases: { default: { about: 'Pick the shared source, then return to the local source' } },+ async check(page, ui) {+ const trigger = page.getByTestId('automation-model').getByRole('button');+ await trigger.click();+ await page.getByRole('button', { name: /Shared Anthropic/ }).click();+ await ui.capture('shared-catalog');+ await page.getByText('Claude Sonnet 4.6', { exact: true }).filter({ visible: true }).click();+ await page.waitForFunction(() => document.querySelector('[data-testid="automation-model"]')?.getAttribute('data-device') === 'shared:fixture');+ assert.equal(await page.getByTestId('automation-model').getAttribute('data-provider'), 'anthropic');+ assert.equal(await trigger.locator('[data-remote-source-mark]').count(), 1);+ await ui.capture('shared-selected');+ await trigger.click();+ await page.getByRole('button', { name: 'Anthropic', exact: true }).click();+ await page.getByText('Claude Sonnet 4.6', { exact: true }).filter({ visible: true }).click();+ await page.waitForFunction(() => document.querySelector('[data-testid="automation-model"]')?.getAttribute('data-device') === '');+ assert.equal(await trigger.locator('[data-remote-source-mark]').count(), 0);+ await ui.capture('local-selected');+ },+};diff --git a/apps/desktop/src/main/localDb/__tests__/migrationReplay.test.ts b/apps/desktop/src/main/localDb/__tests__/migrationReplay.test.tsindex 08574e6d71..a7b3d6563e 100644--- a/apps/desktop/src/main/localDb/__tests__/migrationReplay.test.ts+++ b/apps/desktop/src/main/localDb/__tests__/migrationReplay.test.ts@@ -111,7 +111,7 @@ describeMigrationReplay('migration replay', () => {if (shape !== 'missing') db.exec(`CREATE TABLE orca_workers (id TEXT PRIMARY KEY${shape === 'partial' ? ', pending_remote_report TEXT' : ''}); INSERT INTO orca_workers (id) VALUES ('worker-1');`);db.exec("CREATE TABLE bot_delegations (id TEXT PRIMARY KEY)");const result = runMigrationReplay(db, { drizzleDir: drizzleDir(), currentVersion: 124 });- expect(result.applied.map((migration) => migration.seq)).toEqual([125, 126, 127, 128, 129]);+ expect(result.applied.map((migration) => migration.seq)).toEqual([125, 126, 127, 128, 129, 130]);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,6 +216,35 @@ describeMigrationReplay('migration replay', () => {},);+ // 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)!;+ 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 --git a/apps/desktop/src/main/localDb/mapper.ts b/apps/desktop/src/main/localDb/mapper.tsindex 04190be471..2d0be96fd5 100644--- a/apps/desktop/src/main/localDb/mapper.ts+++ b/apps/desktop/src/main/localDb/mapper.ts@@ -699,6 +699,7 @@ export function scheduleToCamel(row: ScheduleRow): Schedule {intervalMs: row.intervalMs ?? undefined,agentKind: row.agentKind as SchedulerAgentKind,modelAgentKind: row.modelAgentKind ?? undefined,+ modelAgentDeviceId: row.modelAgentDeviceId ?? undefined,model: row.model ?? undefined,providerId: row.providerId ?? undefined,effort: row.effort ?? undefined,@@ -751,6 +752,7 @@ export function scheduleCreateToRow(s: Schedule): ScheduleInsert {intervalMs: s.intervalMs ?? null,agentKind: s.agentKind,modelAgentKind: s.modelAgentKind ?? null,+ modelAgentDeviceId: s.modelAgentDeviceId ?? null,model: s.model ?? null,providerId: s.providerId ?? null,effort: (s.effort as ScheduleInsert['effort']) ?? null,@@ -806,6 +808,7 @@ export function schedulePatchToRow(patch: Partial<Schedule>): Partial<ScheduleInif (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, 'effort')) out.effort = (patch.effort as ScheduleInsert['effort']) ?? null;diff --git a/apps/desktop/src/main/localDb/schema.ts b/apps/desktop/src/main/localDb/schema.tsindex e278663cc8..d960967a07 100644--- a/apps/desktop/src/main/localDb/schema.ts+++ b/apps/desktop/src/main/localDb/schema.ts@@ -1431,6 +1431,8 @@ export const schedules = sqliteTable(agentKind: text('agent_kind', { enum: ['claude-code', 'codex', 'pi'] }).notNull(),/** NULL preserves legacy bound-task Harness inheritance. */modelAgentKind: text('model_agent_kind', { enum: ['claude-code', 'codex', 'pi'] }),+ /** NULL inherits a bound task; empty string explicitly selects the automation host. */+ modelAgentDeviceId: text('model_agent_device_id'),model: text('model'),/*** 显式选定的供应商(来源)id。NULL = 回落该 agent 原生默认来源(no-break,diff --git a/apps/desktop/src/main/maker-host/__tests__/model-route-guard-live.test.ts b/apps/desktop/src/main/maker-host/__tests__/model-route-guard-live.test.tsindex 194486098a..ea91cfcfed 100644--- a/apps/desktop/src/main/maker-host/__tests__/model-route-guard-live.test.ts+++ b/apps/desktop/src/main/maker-host/__tests__/model-route-guard-live.test.ts@@ -4,8 +4,10 @@ const h = vi.hoisted(() => ({catalog: { modelRegistry: {} },listProviders: vi.fn(),effectiveSourceIdForModel: vi.fn(),+ readDeviceProviderViews: vi.fn(),}));+vi.mock('@cindy/model-providers', async (importOriginal) => ({findCatalogModel: (await importOriginal<typeof import('@cindy/model-providers')>()).findCatalogModel,connectedProvidersForAgent: vi.fn(() => []),@@ -45,6 +47,24 @@ import {resolveLenientSessionRoute,} from '../model-route-guard-live.js';+// Unit: use the remote authorized catalog even when the local provider has the+// same id. An offline/revoked share must fail before trying local credentials.+describe('scheduled remote model catalog', () => {+ it('resolves only the selected computer catalog and preserves its axes', async () => {+ vi.clearAllMocks();+ h.readDeviceProviderViews.mockResolvedValue([{ id: 'shared-provider', connected: true,+ models: { pi: [{ id: 'remote-model', efforts: ['high'], defaultEffort: 'high', supportsFastMode: false }] } }]);+ const choice = { agentKind: 'pi' as const, agentDeviceId: 'shared:owner', model: 'remote-model',+ providerId: 'shared-provider', effort: 'ultra' as const, fastMode: true };+ await expect(resolveScheduledModelSelectionLive(choice, h.readDeviceProviderViews)).resolves.toMatchObject({ ...choice, effort: 'high', fastMode: false });+ expect(h.listProviders).not.toHaveBeenCalled();+ expect(h.readDeviceProviderViews).toHaveBeenCalledWith('shared:owner');+ h.readDeviceProviderViews.mockRejectedValueOnce(new Error('[REMOTE_AGENT_SHARE_REMOVED] removed'));+ await expect(resolveScheduledModelSelectionLive(choice, h.readDeviceProviderViews)).rejects.toThrow('REMOTE_AGENT_SHARE_REMOVED');+ expect(h.listProviders).not.toHaveBeenCalled();+ });+});+describe('resolveDefaultScheduleRoute', () => {beforeEach(() => {vi.clearAllMocks();diff --git a/apps/desktop/src/main/maker-host/model-route-guard-live.ts b/apps/desktop/src/main/maker-host/model-route-guard-live.tsindex 3383cd0080..4da43d5f06 100644--- a/apps/desktop/src/main/maker-host/model-route-guard-live.ts+++ b/apps/desktop/src/main/maker-host/model-route-guard-live.ts@@ -25,6 +25,7 @@ import {} from '@cindy/model-providers';import { resolveNewTaskDefaultRoute } from '../../shared/draftModelCalibration.js';+import { checkDeviceRoute } from '../remote-agent/controller/deviceRouteCheck.js';import { activeOwnerScopeKey } from '../appSessionState.js';import { resolveScheduledModelSelection, type ScheduledModelSelection } from '../maker-ipc/scheduledModelSelection';import { getDesktopProviderService } from './createDesktopProviderService.js';@@ -302,7 +303,18 @@ export async function resolveLenientSessionRoute(/** Resolve one provider-specific snapshot after route admission for fresh and bound sends. */export async function resolveScheduledModelSelectionLive(selection: ScheduledModelSelection,+ readRemoteProviders?: (agentDeviceId: string) => Promise<ProviderView[]>,): Promise<ScheduledModelSelection> {+ 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 --git a/apps/desktop/src/main/maker-ipc/__tests__/scheduleIntervalJsonBoundary.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/scheduleIntervalJsonBoundary.test.tsindex 421ae0c33f..fe5c0e6261 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/scheduleIntervalJsonBoundary.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/scheduleIntervalJsonBoundary.test.ts@@ -127,6 +127,19 @@ describe('normalizeLegacyDeviceLinkIntervalClear(旧版 mobile 的清空兼容)'describe('scheduled model selection IPC compatibility', () => {+ // Integration: a shared provider id must never enter the local utility HTTP+ // generator, even if a local provider happens to have that same id.+ it('reports unsupported remote script generation before looking up local credentials', async () => {+ const getMaker = vi.fn(() => null);+ registerScheduleHandlers(getMaker);+ const result = await handlers.get('maker:schedule:generate-pre-run-hook')!(null, {+ description: 'check changes', modelAgentDeviceId: 'shared:owner', providerId: 'same-id',+ agentKind: 'codex', model: 'remote-model',+ });+ expect(result).toMatchObject({ ok: false, reason: 'no_candidate',+ attempts: [{ providerId: 'same-id', model: 'remote-model', reason: 'unsupported_transport' }] });+ expect(getMaker).not.toHaveBeenCalled();+ });const existing = { id: 'bound-schedule', targetSessionId: 'bound', agentKind: 'codex',modelAgentKind: 'pi', model: 'pi-model', providerId: 'pi-source', effort: 'high', fastMode: true } as Schedule;const fullForm = { cronExpr: '0 9 * * *', manual: false, notify: { desktop: true, feishu: false },diff --git a/apps/desktop/src/main/maker-ipc/__tests__/scheduledModelSelection.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/scheduledModelSelection.test.tsindex cc0da87806..0abb6c2847 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/scheduledModelSelection.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/scheduledModelSelection.test.ts@@ -13,10 +13,12 @@ describe('one-run automation model preferences', () => {function scopeFixture(effort: ScheduledModelSelection['effort'] | '' = 'high',fastMode: ScheduledModelSelection['fastMode'] = true,+ agentDeviceId?: string | null,) {const original: ScheduledModelSelection = {agentKind: 'codex', model: 'owner-model', providerId: 'owner-provider',effort: effort || null, fastMode,+ ...(agentDeviceId !== undefined ? { agentDeviceId } : {}),};let profile = { ...original, effort };let baseline: string | null = null;@@ -28,7 +30,8 @@ describe('one-run automation model preferences', () => {isBusy: vi.fn(() => false),apply: vi.fn(async (_id: string, value: ScheduledModelSelection) => {const { agentKind, model, providerId, effort, fastMode } = value;- profile = { agentKind, model, providerId, effort, fastMode };+ profile = { agentKind, model, providerId, effort, fastMode,+ ...(value.agentDeviceId !== undefined ? { agentDeviceId: value.agentDeviceId } : {}) };}),};return { original, deps, scope: createScheduledModelScope(deps),@@ -45,6 +48,14 @@ describe('one-run automation model preferences', () => {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 });+ });// 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.@@ -123,6 +134,30 @@ function fixture(agentKind: ScheduledModelSelection['agentKind'] = 'codex') {}describe('saved automation model selection at dispatch', () => {+ // Unit: same-Harness source changes previously skipped history handoff. Exercise+ // both directions plus legacy inheritance through the real selection entry point.+ it.each([+ { current: null, chosen: 'shared:owner', expected: 'shared:owner', switches: true },+ { current: 'shared:owner', chosen: null, expected: null, switches: true },+ { current: 'shared:owner', chosen: undefined, expected: 'shared:owner', switches: false },+ ])('applies the selected Agent location: %j', async ({ current, chosen, expected, switches }) => {+ const deps = { ...fixture('pi'), getTarget: async () => ({+ agentKind: 'pi' as const, status: 'active', agentDeviceId: current,+ }) };+ const resolved = await applyScheduledModelSelection({ ...selection, agentDeviceId: chosen }, deps);+ expect(resolved.agentDeviceId).toBe(expected);+ expect(deps.switchHarness).toHaveBeenCalledTimes(switches ? 1 : 0);+ expect(deps.applyModel).toHaveBeenCalledWith(expect.objectContaining({ agentDeviceId: expected }));+ });++ it('keeps the current task intact when the shared route is unavailable', async () => {+ const deps = fixture('pi');+ deps.resolveSelection.mockRejectedValueOnce(new Error('shared provider offline'));+ await expect(applyScheduledModelSelection({ ...selection, agentDeviceId: 'shared:owner' }, deps))+ .rejects.toThrow('offline');+ expect(deps.switchHarness).not.toHaveBeenCalled();+ expect(deps.applyModel).not.toHaveBeenCalled();+ });it('hands history to the target Harness before applying the complete model configuration', async () => {const deps = fixture();await applyScheduledModelSelection(selection, deps);@@ -240,6 +275,8 @@ describe('bound target Harness capability', () => {'rejects cross-Harness overrides on %j while preserving same-Harness and follow modes', (restriction) => {const target = { agentKind: 'codex' as const, status: 'active', ...restriction };expect(() => assertScheduledHarnessSupported(target, 'pi')).toThrow('current Harness');+ expect(() => assertScheduledHarnessSupported(target, 'codex', 'shared:owner')).toThrow('current Harness');+ expect(() => assertScheduledHarnessSupported(target, 'codex', null)).not.toThrow();expect(() => assertScheduledHarnessSupported(target, 'codex')).not.toThrow();expect(() => assertScheduledHarnessSupported(target, undefined)).not.toThrow();},diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.tsindex 74622fc950..3184b903d2 100644--- a/apps/desktop/src/main/maker-ipc/register.ts+++ b/apps/desktop/src/main/maker-ipc/register.ts@@ -195,7 +195,7 @@ import {readInputDeliveryClientIds,} from '@cindy/device-link';import { and, asc, desc, eq, gte, inArray, isNull, like, lt, or, sql } from 'drizzle-orm';-import { applyScheduledModelSelection, createScheduledModelScope, ScheduledModelSelectionBusyError, type ScheduledModelSelection, type ScheduledModelSelectionLease } from './scheduledModelSelection';+import { applyScheduledModelSelection, createScheduledModelScope, resolveScheduledModelSelection, ScheduledModelSelectionBusyError, type ScheduledModelSelection, type ScheduledModelSelectionLease } from './scheduledModelSelection';import { parseScheduledModelBaseline } from '../../shared/scheduledModelBaseline';import { recordTurnModelChange, type TurnModelIdentity } from './turnModelChange';import { app, BrowserWindow, dialog, ipcMain, shell, type IpcMainInvokeEvent } from 'electron';@@ -6437,11 +6437,13 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)const projectScheduledPreferences = (sessionId: string, saved: ScheduledModelSelection) => {const baseline: ScheduledModelSelection = {agentKind: saved.agentKind, model: saved.model, providerId: saved.providerId,+ ...(saved.agentDeviceId !== undefined ? { agentDeviceId: saved.agentDeviceId } : {}),effort: saved.effort, fastMode: saved.fastMode,};return {...projectSessionRuntimeControl(sessionId, baseline),agentKind: makerToDbAgentKind(baseline.agentKind),+ ...(baseline.agentDeviceId !== undefined ? { agentDeviceId: baseline.agentDeviceId } : {}),model: baseline.model,providerId: baseline.providerId,effort: baseline.effort ?? '',@@ -6952,6 +6954,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)supportsSchedulePreRunHook: true,// Full scheduled model selection, including bound Harness changes and template overrides.supportsScheduleModelSelection: true,+ supportsScheduleAgentDeviceSelection: true,};});@@ -10879,10 +10882,12 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)getTarget: async () => {const row = await agentSwitchDeps.getSessionRow(sessionId);return row ? { agentKind: dbToMakerAgentKind(row.agentKind), status: row.status,- remoteHostId: row.remoteHostId, orcaRole: row.orcaRole } : null;+ agentDeviceId: row.agentDeviceId, remoteHostId: row.remoteHostId, orcaRole: row.orcaRole } : null;},isBusy: () => isSessionInTurn(sessionId) || !!maker.getSession(sessionId)?.isTurnRunning(),resolveSelection: async (route) => {+ if (route.agentDeviceId) return resolveScheduledModelSelection(route,+ await readUsableAgentDeviceProviders(route.agentDeviceId, route.agentKind, route.model, route.providerId));const reroute = await assertModelRouteUsable(route.agentKind, route.model, route.providerId);return resolveScheduledModelSelectionLive({ ...route,providerId: reroute && shouldApplyExclusiveProviderRerouteLive(route.providerId)@@ -10897,6 +10902,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)...agentSwitchDeps, pendingSwitches: undefined, onPendingSwitchChanged: undefined,}, {sessionId, targetAgentKind: route.agentKind, model: route.model,+ agentDeviceId: route.agentDeviceId,providerId: route.providerId, effort: route.effort, fastMode: route.fastMode,applyNow: true, configStaged: true, signal,});@@ -10925,10 +10931,12 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)const [row] = await getDbClient().drizzle.select({agentKind: sessions.agentKind, model: sessions.model, providerId: sessions.providerId,effort: sessions.effort, fastMode: sessions.fastMode, baseline: sessions.scheduledModelBaseline,+ agentDeviceId: sessions.agentDeviceId,status: sessions.status,}).from(sessions).where(eq(sessions.id, sessionId)).limit(1);return row?.status === 'active' ? { baseline: row.baseline, profile: {agentKind: dbToMakerAgentKind(row.agentKind), model: row.model, providerId: row.providerId,+ agentDeviceId: row.agentDeviceId,effort: row.effort, fastMode: row.fastMode,} } : null;},@@ -10976,9 +10984,11 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions).from(sessions).where(eq(sessions.id, sessionId)).limit(1);const baseline = parseScheduledModelBaseline(row?.baseline);if (!baseline) return false;- const providers = await getDesktopProviderService().listProviders({- allowSideEffects: false, catalog: getActiveCatalog(),- });+ const providers = baseline.agentDeviceId+ ? await readUsableAgentDeviceProviders(baseline.agentDeviceId, baseline.agentKind, baseline.model, baseline.providerId)+ : await getDesktopProviderService().listProviders({+ allowSideEffects: false, catalog: getActiveCatalog(),+ });const providerId = baseline.providerId ??effectiveSourceIdForModel(providers, null, baseline.model, baseline.agentKind);const model = findCatalogModel(providers.find(p => p.id === providerId),diff --git a/apps/desktop/src/main/maker-ipc/schedule.ts b/apps/desktop/src/main/maker-ipc/schedule.tsindex f3363e0634..35916ba1ce 100644--- a/apps/desktop/src/main/maker-ipc/schedule.ts+++ b/apps/desktop/src/main/maker-ipc/schedule.ts@@ -312,6 +312,7 @@ function buildCreateScheduleInput(intervalMs: overrides.intervalMs,agentKind: overrides.agentKind ?? template.agentKind ?? 'claude-code',modelAgentKind: overrides.modelAgentKind,+ modelAgentDeviceId: overrides.modelAgentDeviceId,model: overrides.model ?? template.model,providerId: overrides.providerId ?? template.providerId,effort: overrides.effort ?? template.effort,@@ -475,6 +476,16 @@ export function registerScheduleHandlers(getMaker?: () => Maker | null): void {ipcMain.handle(MAKER_INVOKE.SCHEDULE_GENERATE_PRE_RUN_HOOK, async (event, payload: unknown) => {const body = requireObject(payload, 'payload');const description = requireString(body.description, 'description');+ // The script helper uses direct utility HTTP calls. Never interpret a remote+ // provider id as a local credential (including a coincidentally identical id).+ const unsupportedRemoteGeneration = (providerId: unknown, model: unknown, agentKind: unknown) => ({+ ok: false as const, reason: 'no_candidate' as const,+ attempts: [{ providerId: typeof providerId === 'string' ? providerId : '',+ model: typeof model === 'string' ? model : '',+ transport: agentKind === 'codex' ? 'codex-responses' as const : 'litellm-chat-completions' as const,+ status: 'skipped' as const, reason: 'unsupported_transport' as const }],+ });+ if (body.modelAgentDeviceId) return unsupportedRemoteGeneration(body.providerId, body.model, body.agentKind);const maker = getMaker?.();if (!maker) throwIpcError('INTERNAL', 'maker not ready for hook script generation');const workingDir = await resolveHookWorkingDir(body);@@ -494,6 +505,7 @@ export function registerScheduleHandlers(getMaker?: () => Maker | null): void {resolveBoundSessionRoute: body.resolveBoundSessionRoute === true,})) {const session = await maker.getSessionMeta(targetSessionId).catch(() => null);+ if (session?.agentDeviceId) return unsupportedRemoteGeneration(providerId, model ?? session.model, session.agentKind);// Bound-session fallback must use the same live connection snapshot as// the provider picker. Never turn an unconnected built-in provider into// a routable candidate just because it exists in the catalog.diff --git a/apps/desktop/src/main/maker-ipc/scheduledModelSelection.ts b/apps/desktop/src/main/maker-ipc/scheduledModelSelection.tsindex 4e7901f5f6..bfcd62eaa2 100644--- a/apps/desktop/src/main/maker-ipc/scheduledModelSelection.ts+++ b/apps/desktop/src/main/maker-ipc/scheduledModelSelection.ts@@ -6,6 +6,8 @@ import { parseScheduledModelBaseline, type ScheduledModelBaseline } from '../..//** A saved automation choice, applied only while its target's send lock is held. */export interface ScheduledModelSelection {agentKind: AgentKind;+ /** Undefined inherits a bound task; null explicitly selects the task host. */+ agentDeviceId?: string | null;model: string;providerId: string | null;effort: Effort | null;@@ -66,6 +68,7 @@ export class ScheduledModelSelectionBusyError extends Error {}interface ScheduledModelTarget {agentKind: AgentKind;+ agentDeviceId?: string | null;status: string;remoteHostId?: string | null;orcaRole?: string | null;@@ -75,8 +78,12 @@ interface ScheduledModelTarget {export function assertScheduledHarnessSupported(target: ScheduledModelTarget | null,agentKind: AgentKind | undefined,+ agentDeviceId?: string | null,): void {- if (target?.status !== 'active' || !agentKind || target.agentKind === agentKind) return;+ if (target?.status !== 'active') return;+ const changesHarness = agentKind && target.agentKind !== agentKind;+ const changesDevice = agentDeviceId !== undefined && agentDeviceId !== (target.agentDeviceId ?? null);+ if (!changesHarness && !changesDevice) return;if (target.remoteHostId || target.orcaRole) {throw new Error('SSH and Orca automation targets must keep their current Harness');}@@ -119,9 +126,12 @@ export async function applyScheduledModelSelection(return deps.resolveSelection(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 --git a/apps/desktop/src/main/mcp-integrations/__tests__/schedulerDevices.test.ts b/apps/desktop/src/main/mcp-integrations/__tests__/schedulerDevices.test.tsindex 1b73586aae..168f71a8e0 100644--- a/apps/desktop/src/main/mcp-integrations/__tests__/schedulerDevices.test.ts+++ b/apps/desktop/src/main/mcp-integrations/__tests__/schedulerDevices.test.ts@@ -27,6 +27,17 @@ function setup(invoke = vi.fn<Invoke>(async () => ({ ok: true, result: [] }))) {}describe('desktop scheduler cross-device transport', () => {+ // Unit: an old host ignores the new route field; reject before a write can run locally instead.+ it.each([false, true])('checks remote schedule location support before writing (%s)', async (supported) => {+ const s = setup();+ s.invoke.mockResolvedValueOnce({ ok: true, result: { supportsScheduleAgentDeviceSelection: supported } });+ s.invoke.mockResolvedValueOnce({ ok: true, result: { id: 's1' } });+ const result = await s.remote.invoke('mac', 'update', ['s1', { modelAgentDeviceId: 'shared:owner' }]);+ expect(s.invoke.mock.calls[0].slice(0, 3)).toEqual(['mac', 'maker:get-capabilities', ['claude-code']]);+ expect(s.invoke).toHaveBeenCalledTimes(supported ? 2 : 1);+ expect(result.ok).toBe(supported);+ if (!supported) expect(result).toMatchObject({ code: 'REMOTE_UNSUPPORTED' });+ });it('reuses the existing remote-control schedule channels with their argument shapes', async () => {const s = setup();await s.remote.invoke('mac', 'list', [{ status: 'active' }]);diff --git a/apps/desktop/src/main/mcp-integrations/schedulerDevices.ts b/apps/desktop/src/main/mcp-integrations/schedulerDevices.tsindex 038edc3654..7511594917 100644--- a/apps/desktop/src/main/mcp-integrations/schedulerDevices.ts+++ b/apps/desktop/src/main/mcp-integrations/schedulerDevices.ts@@ -100,6 +100,14 @@ export function createSchedulerRemoteDeps(deps: {}let response: InvokeResultPayload;try {+ const patch = op === 'update' ? args[1] as Record<string, unknown> | undefined : undefined;+ if (patch && Object.prototype.hasOwnProperty.call(patch, 'modelAgentDeviceId')) {+ const capabilities = await deps.invoke(deviceId, 'maker:get-capabilities', ['claude-code'], { preSend: assertCurrent });+ assertCurrent();+ if (!capabilities.ok || !(capabilities.result as { supportsScheduleAgentDeviceSelection?: boolean } | null)?.supportsScheduleAgentDeviceSelection) {+ return { ok: false, code: 'REMOTE_UNSUPPORTED', message: '目标电脑的版本不支持自动化选择远程或分享供应商,请先更新目标电脑' };+ }+ }response = await deps.invoke(deviceId, CHANNELS[op], args, { preSend: assertCurrent });} catch (error) {if (error instanceof DeviceLinkError) {diff --git a/apps/desktop/src/main/scheduler-host/__tests__/project-automation-loader.test.ts b/apps/desktop/src/main/scheduler-host/__tests__/project-automation-loader.test.tsindex a845af25de..9b680588e8 100644--- a/apps/desktop/src/main/scheduler-host/__tests__/project-automation-loader.test.ts+++ b/apps/desktop/src/main/scheduler-host/__tests__/project-automation-loader.test.ts@@ -97,22 +97,25 @@ describe('project automation explicit Harness reconciliation', () => {it('detects marker-only changes, persists them, and clears them without losing the bound task', () => {const current: Schedule = { ...projectSchedule({ desktop: true, feishu: false }),agentKind: 'pi', model: 'test-model', persistentSession: true, targetSessionId: 'bound-codex' };- const config = projectConfig({ agentKind: 'pi', modelAgentKind: 'pi', model: 'test-model', persistentSession: true });+ const config = projectConfig({ agentKind: 'pi', modelAgentKind: 'pi', modelAgentDeviceId: 'shared:owner',+ providerId: 'shared-source', model: 'test-model', persistentSession: true });expect(schedulesDiffer(current, config, workingDir)).toBe(true);const input = __testing.scheduleConfigToUpdateInput(config, workingDir);expect(input.modelAgentKind).toBe('pi');+ expect(input.modelAgentDeviceId).toBe('shared:owner');const saved = scheduleToCamel({ ...scheduleCreateToRow(current),- ...schedulePatchToRow({ modelAgentKind: input.modelAgentKind }),+ ...schedulePatchToRow({ modelAgentKind: input.modelAgentKind, modelAgentDeviceId: input.modelAgentDeviceId,+ providerId: input.providerId }),} as Parameters<typeof scheduleToCamel>[0]);expect(saved).toMatchObject({ modelAgentKind: 'pi', persistentSession: true, targetSessionId: 'bound-codex' });expect(schedulesDiffer(saved, config, workingDir)).toBe(false);- const legacy = { ...config, modelAgentKind: undefined };+ const legacy = { ...config, modelAgentKind: undefined, modelAgentDeviceId: undefined };expect(schedulesDiffer(saved, legacy, workingDir)).toBe(true);const clearInput = __testing.scheduleConfigToUpdateInput(legacy, workingDir);expect(clearInput).toHaveProperty('modelAgentKind', undefined);const cleared = scheduleToCamel({ ...scheduleCreateToRow(saved),- ...schedulePatchToRow({ modelAgentKind: clearInput.modelAgentKind }),+ ...schedulePatchToRow({ modelAgentKind: clearInput.modelAgentKind, modelAgentDeviceId: clearInput.modelAgentDeviceId }),} as Parameters<typeof scheduleToCamel>[0]);expect(cleared.modelAgentKind).toBeUndefined();expect(cleared.targetSessionId).toBe('bound-codex');diff --git a/apps/desktop/src/main/scheduler-host/__tests__/runnerModelSelection.test.ts b/apps/desktop/src/main/scheduler-host/__tests__/runnerModelSelection.test.tsindex 38980cc8cb..aef3f7bfa1 100644--- a/apps/desktop/src/main/scheduler-host/__tests__/runnerModelSelection.test.ts+++ b/apps/desktop/src/main/scheduler-host/__tests__/runnerModelSelection.test.ts@@ -332,6 +332,25 @@ describe('MakerScheduleRunner model selection', () => {mocks.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(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.it.each([diff --git a/apps/desktop/src/main/scheduler-host/__tests__/runnerQueuedDispatch.test.ts b/apps/desktop/src/main/scheduler-host/__tests__/runnerQueuedDispatch.test.tsindex 2d313ef0dc..f5c070e540 100644--- a/apps/desktop/src/main/scheduler-host/__tests__/runnerQueuedDispatch.test.ts+++ b/apps/desktop/src/main/scheduler-host/__tests__/runnerQueuedDispatch.test.ts@@ -593,10 +593,13 @@ describe('MakerScheduleRunner queued dispatch (busy bound session)', () => {{ agentKind: 'pi' as const, effort: null, fastMode: false },{ agentKind: 'pi' as const, effort: 'high' as const, fastMode: true },{ agentKind: 'codex' as const, effort: 'high' as const, fastMode: false },+ { agentKind: 'pi' as const, effort: 'high' as const, fastMode: false, agentDeviceId: 'shared:owner' },+ { agentKind: 'codex' as const, effort: 'high' as const, fastMode: false, agentDeviceId: 'shared:owner' },])('keeps the resolved selection through queue acceptance: %j', async (axes) => {const h = createSessionHarness(async () => ({ accepted: true }));const setFastMode = vi.fn(async () => {});- Object.assign(h.session, { agentKind: axes.agentKind, model: 'shared-model', setFastMode });+ Object.assign(h.session, { agentKind: axes.agentKind, model: 'shared-model', setFastMode,+ agentDeviceId: 'agentDeviceId' in axes ? axes.agentDeviceId : null });mocks.getSessionProvider.mockReturnValue('selected');const queue = createQueueHarness({ busy: false });const release = vi.fn();@@ -617,6 +620,7 @@ describe('MakerScheduleRunner queued dispatch (busy bound session)', () => {const schedule = heartbeatSchedule({agentKind: axes.agentKind,modelAgentKind: axes.agentKind,+ modelAgentDeviceId: 'agentDeviceId' in axes ? axes.agentDeviceId : undefined,model: 'shared-model',effort: 'ultra',fastMode: true,@@ -652,6 +656,46 @@ describe('MakerScheduleRunner queued dispatch (busy bound session)', () => {expect(schedule).toEqual(saved);});+ // Review regression (integration): the previous matrix only kept the same live+ // location. An identical provider/model on another device must never receive+ // this run. Exercise both preparation and accepted-before-vendor boundaries.+ it.each([+ { agentKind: 'pi' as const, boundary: 'preparing', nextDevice: 'shared:other' },+ { agentKind: 'codex' as const, boundary: 'preparing', nextDevice: null },+ { agentKind: 'pi' as const, boundary: 'accepted', nextDevice: null },+ { agentKind: 'codex' as const, boundary: 'accepted', nextDevice: 'shared:other' },+ ])('rejects a changed Agent location at queue dispatch: %j', async ({ agentKind, boundary, nextDevice }) => {+ const h = createSessionHarness(async () => ({ accepted: true }));+ const selection = { agentKind, agentDeviceId: 'shared:selected', model: 'shared-model',+ providerId: 'selected', effort: null, fastMode: false };+ Object.assign(h.session, selection);+ mocks.getSessionProvider.mockReturnValue('selected');+ const queue = createQueueHarness({ busy: false });+ const { runner, replaceLiveSession } = createRunnerHarness(h.session, queue.deps, {+ metaModel: selection.model,+ acquirePendingAgentSwitch: async () => ({ release: vi.fn(), selection }),+ });+ const result = runner.fire(heartbeatSchedule({ agentKind, modelAgentKind: agentKind,+ modelAgentDeviceId: selection.agentDeviceId, model: selection.model, providerId: selection.providerId }),+ createFireContext()).catch((error: unknown) => error);+ await vi.waitFor(() => expect(queue.enqueueCalls).toHaveLength(1));+ const request = enqueueLast(queue);+ if (boundary === 'accepted') await request.onPreparing?.();+ const changed = createSessionHarness(async () => ({ accepted: true }));+ Object.assign(changed.session, selection, { agentDeviceId: nextDevice,+ setFastMode: vi.fn(async () => {}), setEffort: vi.fn(async () => {}) });+ replaceLiveSession(changed.session);+ if (boundary === 'accepted') await request.onAccepted({ permissionMode: 'ask', planMode: false });+ else await queue.accept();+ // Let an incorrectly accepted send finish so the assertion reports success+ // vs failure instead of merely timing out on the pre-fix implementation.+ changed.emit({ type: 'done', data: {}, source: agentKind });+ expect(await result).toBeInstanceOf(Error);+ expect(String(await result)).toContain('Scheduled model route changed');+ expect(changed.setModel).not.toHaveBeenCalled();+ if (boundary === 'accepted') expect(changed.session.abort).toHaveBeenCalledTimes(1);+ });+it.each(['harness-changed', 'effort-failed', 'fast-failed'] as const)('blocks queued dispatch if the resolved selection cannot be honored (%s)',async (failure) => {diff --git a/apps/desktop/src/main/scheduler-host/__tests__/scriptCapabilityBroker.test.ts b/apps/desktop/src/main/scheduler-host/__tests__/scriptCapabilityBroker.test.tsindex 5af4a0e79b..9d32a705a9 100644--- a/apps/desktop/src/main/scheduler-host/__tests__/scriptCapabilityBroker.test.ts+++ b/apps/desktop/src/main/scheduler-host/__tests__/scriptCapabilityBroker.test.ts@@ -545,6 +545,20 @@ describe('SchedulerScriptCapabilityBroker', () => {expect(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 () => {+ await expect(new SchedulerScriptCapabilityBroker().call(+ { method: 'sessions.dispatch', params: { message: 'run task' } },+ new Set(['sessions.dispatch']),+ { schedule: schedule({ modelAgentDeviceId: 'shared:owner', modelAgentKind: 'codex' }) },+ )).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 --git a/apps/desktop/src/main/scheduler-host/__tests__/storage.test.ts b/apps/desktop/src/main/scheduler-host/__tests__/storage.test.tsindex a08950048a..362d9845e1 100644--- a/apps/desktop/src/main/scheduler-host/__tests__/storage.test.ts+++ b/apps/desktop/src/main/scheduler-host/__tests__/storage.test.ts@@ -146,6 +146,15 @@ describe('scheduleToCamel', () => {});describe('scheduleCreateToRow', () => {+ // Unit: preserve the three location states across storage and partial edits.+ it.each([undefined, '', 'shared:owner'])('round-trips Agent location %j without changing prior fields', (modelAgentDeviceId) => {+ const original = baseSchedule({ modelAgentDeviceId, modelAgentKind: 'codex', model: 'remote-model', providerId: 'remote-provider' });+ const row = scheduleCreateToRow(original);+ const renamed = scheduleToCamel({ ...row, ...schedulePatchToRow({ name: 'renamed' }) } as ScheduleRowLike);+ expect(renamed).toMatchObject({ ...original, name: 'renamed' });+ const cleared = scheduleToCamel({ ...row, ...schedulePatchToRow({ modelAgentDeviceId: undefined }) } as ScheduleRowLike);+ expect(cleared.modelAgentDeviceId).toBeUndefined();+ });it('round-trips an explicit model Harness and clears it without changing the legacy agent', () => {const original = baseSchedule({ agentKind: 'codex', modelAgentKind: 'pi', model: 'test-model', providerId: 'custom', fastMode: true });const row = scheduleCreateToRow(original);diff --git a/apps/desktop/src/main/scheduler-host/index.ts b/apps/desktop/src/main/scheduler-host/index.tsindex 1d0cfec1b5..a4cc15b9c4 100644--- a/apps/desktop/src/main/scheduler-host/index.ts+++ b/apps/desktop/src/main/scheduler-host/index.ts@@ -28,6 +28,7 @@ import { getDbClient } from '../localDb/client/current';import { isReviewSessionSource } from '../../shared/sessionSource.js';import { dbToMakerAgentKind } from '../../shared/agentKindConversion.js';import { assertScheduledHarnessSupported } from '../maker-ipc/scheduledModelSelection';+import { readRemoteProviderRoute } from '../remote-agent/controller/deviceCatalog.js';import {resolveDefaultScheduleRoute,resolveRouteCopyCapabilities,@@ -134,7 +135,9 @@ async function startSchedulerInternal(deps: StartSchedulerDeps): Promise<SchedulpreserveModelPreferences: preserveScheduledModelPreferencesUnderLock,onModelDispatched: recordDispatchedModel,applyPiModelSelectionUnderLock: applyPiImModelSelectionUnderLock,- resolveModelSelection: resolveScheduledModelSelectionLive,+ resolveModelSelection: (selection) => resolveScheduledModelSelectionLive(selection, async (agentDeviceId) => [+ (await readRemoteProviderRoute({ ...selection, agentDeviceId })).provider,+ ]),onSessionCreated: broadcastSessionCreated,// 停用轴裁决:每次 fire 前判保存路由是否已被用户停用(见 runner deps 注释)。checkModelRoute: verdictForModelRoute,@@ -215,7 +218,8 @@ async function startSchedulerInternal(deps: StartSchedulerDeps): Promise<Schedulconst [row] = await deps.getDb().select({ source: sessions.source, agentKind: sessions.agentKind,- status: sessions.status, remoteHostId: sessions.remoteHostId, orcaRole: sessions.orcaRole })+ status: sessions.status, agentDeviceId: sessions.agentDeviceId,+ remoteHostId: sessions.remoteHostId, orcaRole: sessions.orcaRole }).from(sessions).where(eq(sessions.id, targetSessionId)).limit(1);@@ -224,7 +228,8 @@ async function startSchedulerInternal(deps: StartSchedulerDeps): Promise<Schedul}assertScheduledHarnessSupported(row ? {...row, agentKind: dbToMakerAgentKind(row.agentKind),- } : null, selection.modelAgentKind);+ } : null, selection.modelAgentKind, selection.modelAgentDeviceId === undefined+ ? undefined : selection.modelAgentDeviceId || null);},// 卡死收口的通知出口。通知投递平时住在两个 runner 里(它们各自持 notifier),而// 卡死收口刻意绕过 runner —— 要么它压根不返回、要么它把守卫 abort 当普通中断处理。diff --git a/apps/desktop/src/main/scheduler-host/project-automation-loader.ts b/apps/desktop/src/main/scheduler-host/project-automation-loader.tsindex 4a3caaabdb..e7928e827c 100644--- a/apps/desktop/src/main/scheduler-host/project-automation-loader.ts+++ b/apps/desktop/src/main/scheduler-host/project-automation-loader.ts@@ -50,6 +50,7 @@ export interface ProjectScheduleConfig {agentKind?: 'claude-code' | 'codex' | 'pi';/** 显式模型选择的 Harness;省略时保留旧配置的跟随绑定任务语义。 */modelAgentKind?: 'claude-code' | 'codex' | 'pi';+ modelAgentDeviceId?: string;model?: string;/** 可选:显式来源(供应商)id。省略 → 走原生默认来源(与旧配置字节级一致)。详见 Schedule.providerId。 */providerId?: string;@@ -457,6 +458,7 @@ function scheduleConfigToCreateInput(agentKind: config.agentKind ?? 'claude-code',// 恒带 key:配置删除显式选择后,reconcile 清除已保存的标记。modelAgentKind: config.modelAgentKind,+ modelAgentDeviceId: config.modelAgentDeviceId,model: config.model,providerId: config.providerId,effort: config.effort,@@ -498,6 +500,7 @@ export function schedulesDiffer(schedule.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.effort !== expected.effort ||@@ -567,6 +570,9 @@ function isProjectScheduleConfig(value: unknown): value is ProjectScheduleConfigoptionalNumber(config.intervalMs) &&optionalAgentKind(config.agentKind) &&optionalAgentKind(config.modelAgentKind) &&+ (config.modelAgentDeviceId === undefined || (typeof config.modelAgentDeviceId === 'string' &&+ (config.modelAgentDeviceId === '' || (config.modelAgentDeviceId.trim() !== '' &&+ !!config.modelAgentKind && typeof config.providerId === 'string' && config.providerId.trim() !== '')))) &&(config.modelAgentKind === undefined || (typeof config.model === 'string' && config.model.trim() !== '')) &&optionalString(config.model) &&optionalString(config.providerId) &&diff --git a/apps/desktop/src/main/scheduler-host/runner.ts b/apps/desktop/src/main/scheduler-host/runner.tsindex 4c683ada08..355cc6c8d0 100644--- a/apps/desktop/src/main/scheduler-host/runner.ts+++ b/apps/desktop/src/main/scheduler-host/runner.ts@@ -937,6 +937,7 @@ export class MakerScheduleRunner implements ScheduleRunner {// 持续会话当前选定的来源(供应商)id —— schedule.providerId 留空时沿用它// (与 model 留空沿用 meta.model 对称)。取自 sessions.provider_id 快照,null=未选。let heartbeatProviderId: string | null = null;+ let heartbeatAgentDeviceId: string | null = null;// Fire-local catalog snapshot. Keep the saved preferences untouched, but never// re-read their stale effort/Fast after the host has resolved the actual route.let resolvedSelection: ScheduledModelSelection | undefined;@@ -952,6 +953,7 @@ export class MakerScheduleRunner implements ScheduleRunner {schedule.modelAgentKind && schedule.model?.trim()? {agentKind: schedule.modelAgentKind,+ agentDeviceId: schedule.modelAgentDeviceId === undefined ? undefined : schedule.modelAgentDeviceId || null,model: schedule.model,providerId: schedule.providerId?.trim() || null,effort: (schedule.effort as Effort | undefined) ?? null,@@ -1104,6 +1106,7 @@ export class MakerScheduleRunner implements ScheduleRunner {heartbeatAgentKind = meta?.agentKind;heartbeatFastMode = meta?.fastMode;heartbeatProviderId = row?.providerId ?? null;+ heartbeatAgentDeviceId = row.agentDeviceId ?? null;// A cold heartbeat is still the owner's existing task. Never upgrade it// to the independent-schedule default merely because its runtime was closed.heartbeatPermissions = routinePermissionSnapshot(undefined, {@@ -1243,11 +1246,15 @@ export class MakerScheduleRunner implements ScheduleRunner {(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;// 停用轴准入(PR #744 review):每次 fire 都是新的付费调用,不属于「运行中的会话// 不打断」豁免 —— 保存过的路由被用户停用后,本次 run 必须以明确错误失败(run 历史// 可见),不能继续经停用路由扣费;隐式默认落点被停用而有启用替代拷贝时改路由过去。let reroutedProviderId: string | null = null;- if (this.deps.checkModelRoute) {+ if (this.deps.checkModelRoute && !agentDeviceId) {const verdict = await this.checkRouteFor(isHeartbeat ? sessionId : undefined, effectiveAgentKind, model, createProviderId);if (verdict.kind === 'reject') {throw new Error(@@ -1264,6 +1271,7 @@ export class MakerScheduleRunner implements ScheduleRunner {throw new Error('Scheduled model selection is not available');resolvedSelection = await this.deps.resolveModelSelection({agentKind: effectiveAgentKind,+ agentDeviceId,model,providerId: createProviderId,effort: (schedule.effort as Effort | undefined) ?? null,@@ -1327,7 +1335,7 @@ export class MakerScheduleRunner implements ScheduleRunner {// TOCTOU 窗口(判定后、createSession 前 session 恰好关闭)只会把 fresh spawn 误判// 成复用 → set 失败时多跳过一次落库 → 下次 fire 重试, 方向保守无害。let reusedLiveSession = this.deps.maker.isSessionAlive(sessionId);- if (reusedLiveSession) {+ if (reusedLiveSession && !agentDeviceId) {const liveSession = this.deps.maker.getSession(sessionId);const currentProviderId = getSessionProvider(sessionId) ?? heartbeatProviderId;// 隐式改道(reroutedProviderId)也是本次 fire 的落地来源:跨凭证家族的改道@@ -1457,7 +1465,7 @@ export class MakerScheduleRunner implements ScheduleRunner {});}}- if (isHeartbeat && effectiveAgentKind === 'pi' && !reusedLiveSession && resumeSessionId) {+ if (!agentDeviceId && isHeartbeat && effectiveAgentKind === 'pi' && !reusedLiveSession && resumeSessionId) {if (!this.deps.applyPiModelSelectionUnderLock) {throw new Error('Scheduled Pi model selection is not available');}@@ -1481,6 +1489,7 @@ export class MakerScheduleRunner implements ScheduleRunner {const createSessionOpts = {id: sessionId,agentKind: effectiveAgentKind,+ ...(agentDeviceId ? { agentDeviceId } : {}),workingDir,model,effort: reconciledEffort,@@ -1535,7 +1544,7 @@ export class MakerScheduleRunner implements ScheduleRunner {getSessionProvider(session.id) ??heartbeatProviderId ??null;- const mustSyncReusedPiRoute = reusedLiveSession && effectiveAgentKind === 'pi';+ const mustSyncReusedPiRoute = !resolvedSelection && reusedLiveSession && effectiveAgentKind === 'pi';let modelSwitchApplied = true;if ((heartbeatModelChanged && effectiveAgentKind !== 'pi') || mustSyncReusedPiRoute) {try {@@ -1607,7 +1616,7 @@ export class MakerScheduleRunner implements ScheduleRunner {// runtimeModel===model 且未走 follow(desiredEffort===schedule.effort)时直接复用上方// createSession 已算好的 reconciledEffort,不重复 lookup / 不重复打 reconcile 日志。const runtimeReconciledEffort =- runtimeModel === model && desiredEffort === schedule.effort+ resolvedSelection || (runtimeModel === model && desiredEffort === schedule.effort)? reconciledEffort: this.reconcileEffortForModel(effectiveAgentKind,@@ -1795,7 +1804,7 @@ export class MakerScheduleRunner implements ScheduleRunner {// Resolve Pi's last provider change before listener, abort and handoff// state bind to the Session instance. The transaction may retire it.- if (effectiveAgentKind === 'pi' && this.deps.checkModelRoute) {+ if (!agentDeviceId && effectiveAgentKind === 'pi' && this.deps.checkModelRoute) {const currentProviderId = getSessionProvider(session.id);const verdict = await this.checkRouteFor(session.id, 'pi', runtimeModel, currentProviderId);if (verdict.kind === 'reject') {@@ -1903,7 +1912,7 @@ export class MakerScheduleRunner implements ScheduleRunner {// 凭证切换 / createSession / 模型同步 / 交接准备等多个长 await,期间路由可能// 刚被停用 —— 按**实际将运行的路由**(runtimeModel + 会话此刻的来源)再判一次,// reject 即失败收口,不发出这次新的付费调用。- if (this.deps.checkModelRoute) {+ if (!agentDeviceId && this.deps.checkModelRoute) {const dispatchProviderId = getSessionProvider(session.id);const verdict = await this.checkRouteFor(session.id,@@ -2466,6 +2475,7 @@ export class MakerScheduleRunner implements ScheduleRunner {: 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);}@@ -2899,6 +2909,20 @@ export class MakerScheduleRunner implements ScheduleRunner {return { sessionId, skipped: true, resultText: error.message };}+ private assertQueuedModelSelection(+ live: ReturnType<Maker['getSession']>,+ selection: ScheduledModelSelection | undefined,+ ): void {+ if (!selection) return;+ // Provider/model IDs are only unique within an Agent location. Check the+ // actual runtime at both queue boundaries, after pending user switches.+ if (!live || live.agentKind !== selection.agentKind ||+ (live.agentDeviceId ?? null) !== (selection.agentDeviceId ?? null) ||+ live.model !== selection.model || getSessionProvider(live.id) !== selection.providerId) {+ throw new QueuedRouteDisabledError('Scheduled model route changed before queued dispatch');+ }+ }+/*** 排队派发时刻的路由热同步:schedule 显式设置的 model / effort / 来源(供应商)* 优先于绑定会话当前值(与直发路径 4.4.1/4.4.2 同语义);留空沿用会话当前值。@@ -2923,7 +2947,7 @@ export class MakerScheduleRunner implements ScheduleRunner {const explicitProviderId = schedule.providerId?.trim() || null;const routeProviderId = explicitProviderId ?? currentProviderId;let providerId = routeProviderId;- if (this.deps.checkModelRoute) {+ if (!live?.agentDeviceId && this.deps.checkModelRoute) {const verdict = await this.checkRouteFor(sessionId, 'pi', model, routeProviderId);if (verdict.kind === 'reject') {throw new QueuedRouteDisabledError(@@ -2939,6 +2963,9 @@ export class MakerScheduleRunner implements ScheduleRunner {resolved.providerId !== providerId)) {throw new QueuedRouteDisabledError('Scheduled model route changed before queued dispatch');}+ // The explicit profile already went through the ordinary runtime transaction.+ // Reapplying via the local Pi path would use the automation host's catalog.+ if (resolved) return { model, providerId };if (!this.deps.applyPiModelSelectionUnderLock) {throw new QueuedPiRouteSyncError('Scheduled Pi model selection is not available');}@@ -2965,6 +2992,7 @@ export class MakerScheduleRunner implements ScheduleRunner {},preparedPiRoute: { model: string; providerId: string | null } | null = null,): Promise<void> {+ this.assertQueuedModelSelection(live, baseline.resolvedSelection);const explicitModel = schedule.model?.trim() ? schedule.model : undefined;const targetModel =explicitModel ??@@ -2981,7 +3009,7 @@ export class MakerScheduleRunner implements ScheduleRunner {// 「保持 live 路由继续派发」不行:这次排队心跳本身就是一次新的付费调用,目标// 路由(常等于 live 当前路由)已被停用时照发等于继续经停用路由扣费。let applyProviderId = explicitProviderId;- if (this.deps.checkModelRoute) {+ if (!live.agentDeviceId && this.deps.checkModelRoute) {// 裁决对象 = 本轮实际将使用的来源:schedule 显式配置优先,否则会话当前存的// 来源(它同样是显式路由,provider-route 不查停用标志)—— 只传// explicitProviderId 会在「schedule 未指定来源 + 会话当前来源已被停用」时@@ -3000,6 +3028,7 @@ export class MakerScheduleRunner implements ScheduleRunner {}const nextProviderId = applyProviderId ?? currentProviderId;const resolvedSelection = baseline.resolvedSelection;+ const remoteAgent = Boolean(live.agentDeviceId);if (resolvedSelection &&(live.agentKind !== resolvedSelection.agentKind ||@@ -3009,7 +3038,7 @@ export class MakerScheduleRunner implements ScheduleRunner {throw new QueuedRouteDisabledError('Scheduled model route changed before queued dispatch');}if (- crossesCodexAppliedCustomProviderIdentity({+ !remoteAgent && crossesCodexAppliedCustomProviderIdentity({agentKind: live.agentKind,remoteHostId: live.remoteHostId,currentCodexProxyActive: live.codexProxyActive,@@ -3023,7 +3052,7 @@ export class MakerScheduleRunner implements ScheduleRunner {);}if (- isCodexThreadModelProviderIdentityMismatch({+ !remoteAgent && isCodexThreadModelProviderIdentityMismatch({agentKind: live.agentKind,remoteHostId: live.remoteHostId,currentProviderId,@@ -3040,7 +3069,7 @@ export class MakerScheduleRunner implements ScheduleRunner {);}if (- live.agentKind !== 'pi' &&+ !remoteAgent && live.agentKind !== 'pi' &&shouldCloseSessionForCredentialSwitch({agentKind: live.agentKind,remoteHostId: live.remoteHostId,@@ -3086,7 +3115,7 @@ export class MakerScheduleRunner implements ScheduleRunner {return;}if (- live.agentKind !== 'pi' &&+ !remoteAgent && live.agentKind !== 'pi' &&(await live.requiresModelSwitchRebuild?.(targetModel, { providerId: nextProviderId })) ===true) {diff --git a/apps/desktop/src/main/scheduler-host/script-capability-broker.ts b/apps/desktop/src/main/scheduler-host/script-capability-broker.tsindex 7ec02d3ba1..bf10a4e0cb 100644--- a/apps/desktop/src/main/scheduler-host/script-capability-broker.ts+++ b/apps/desktop/src/main/scheduler-host/script-capability-broker.ts@@ -218,6 +218,9 @@ export class SchedulerScriptCapabilityBroker implements ScriptCapabilityBroker {/** 新建任务的配置:模型留空时按新建任务口径实时解析,不写死型号。 */private async createDefaultsFor(schedule: Schedule) {+ if (schedule.modelAgentDeviceId) {+ 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 --git a/apps/desktop/src/preload/preload.ts b/apps/desktop/src/preload/preload.tsindex 228ad4784e..774fa80884 100644--- a/apps/desktop/src/preload/preload.ts+++ b/apps/desktop/src/preload/preload.ts@@ -8132,6 +8132,7 @@ contextBridge.exposeInMainWorld('electronAPI', {scheduleName?: string;workingDir?: string;providerId?: string;+ modelAgentDeviceId?: string;agentKind?: 'claude-code' | 'codex';model?: string;/** 绑定会话任务:workingDir 空时 main 按会话 meta.workDir 解析落盘/自测目录。 */diff --git a/apps/desktop/src/renderer/__tests__/schedulerModelPopoverOverlay.test.tsx b/apps/desktop/src/renderer/__tests__/schedulerModelPopoverOverlay.test.tsxindex 1850033744..537afe196e 100644--- a/apps/desktop/src/renderer/__tests__/schedulerModelPopoverOverlay.test.tsx+++ b/apps/desktop/src/renderer/__tests__/schedulerModelPopoverOverlay.test.tsx@@ -82,6 +82,8 @@ vi.mock('@/components/new-chat/ModelSelector', () => ({}));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 }) }));vi.mock('@/hooks/useAgentCapabilities', () => ({getCachedCapabilities: () => null,diff --git a/apps/desktop/src/renderer/components/new-chat/ModelRouteSelector.tsx b/apps/desktop/src/renderer/components/new-chat/ModelRouteSelector.tsxindex 50d7ca1267..fdcb417428 100644--- a/apps/desktop/src/renderer/components/new-chat/ModelRouteSelector.tsx+++ b/apps/desktop/src/renderer/components/new-chat/ModelRouteSelector.tsx@@ -1,13 +1,38 @@import type { ComponentProps } from 'react';-import { ModelSelector } from './ModelSelector';+import { ModelSelector, ModelSelectorContent } from './ModelSelector';import { useModelRouteDevices } from '@/hooks/useModelRouteDevices';-/** Settings consume the same location catalog as ordinary tasks and workers. */+interface ModelRouteContext {+ /** The task host; omitted for this computer. */+ deviceId?: string;+ /** The selected Agent location; null/omitted means the task host. */+ agentDeviceId?: string | null;+ sshRemote?: boolean;+}++function useModelRouteOptions({ deviceId, agentDeviceId, sshRemote }: ModelRouteContext) {+ const locations = useModelRouteDevices({+ controlledDeviceId: deviceId ?? null,+ leadAgentDeviceId: agentDeviceId,+ sshRemote,+ });+ return locations.devices ? {+ devices: locations.devices,+ selectedDeviceId: agentDeviceId ?? null,+ homeDeviceId: deviceId,+ } : undefined;+}++/** Full control using the common task/worker location catalog. */export function ModelRouteSelector({ agentDeviceId, sshRemote, deviceId, ...props }:- ComponentProps<typeof ModelSelector> & { agentDeviceId?: string | null; sshRemote?: boolean }) {- const locations = useModelRouteDevices({ controlledDeviceId: deviceId ?? null,- leadAgentDeviceId: agentDeviceId, sshRemote });- return <ModelSelector {...props} deviceId={deviceId}- remoteAgent={locations.devices ? { devices: locations.devices,- selectedDeviceId: agentDeviceId ?? null, homeDeviceId: deviceId } : undefined} />;+ Omit<ComponentProps<typeof ModelSelector>, 'remoteAgent'> & ModelRouteContext) {+ const remoteAgent = useModelRouteOptions({ deviceId, agentDeviceId, sshRemote });+ return <ModelSelector {...props} deviceId={deviceId} remoteAgent={remoteAgent} />;+}++/** The same selector inside an existing popover; callbacks retain the full selection. */+export function ModelRouteSelectorContent({ agentDeviceId, sshRemote, deviceId, ...props }:+ Omit<ComponentProps<typeof ModelSelectorContent>, 'remoteAgent'> & ModelRouteContext) {+ const remoteAgent = useModelRouteOptions({ deviceId, agentDeviceId, sshRemote });+ return <ModelSelectorContent {...props} deviceId={deviceId} remoteAgent={remoteAgent} />;}diff --git a/apps/desktop/src/renderer/features/scheduler/components/ScheduleChips.tsx b/apps/desktop/src/renderer/features/scheduler/components/ScheduleChips.tsxindex 1646fdd46e..516c8b44a6 100644--- a/apps/desktop/src/renderer/features/scheduler/components/ScheduleChips.tsx+++ b/apps/desktop/src/renderer/features/scheduler/components/ScheduleChips.tsx@@ -15,7 +15,10 @@ import {import { useDetectCwd } from '@/hooks/useWorktreeQueries';import { useAgentCapabilities, type ModelDescriptor } from '@/hooks/useAgentCapabilities';import { useProviders } from '@/hooks/useProviders';-import { ModelIconMark, ModelSelectorContent } from '@/components/new-chat/ModelSelector';+import { useDeviceProviders } from '@/hooks/useDeviceProviders';+import { RemoteSourceMark } from '@/components/icons/RemoteSourceMark';+import { ModelIconMark } from '@/components/new-chat/ModelSelector';+import { ModelRouteSelectorContent } from '@/components/new-chat/ModelRouteSelector';import { useModelDiscoveryPending } from '@/components/new-chat/useModelDiscoveryPending';import {effectiveSourceIdForModel,@@ -1048,6 +1051,7 @@ export function ModelEffortChip({onSelect,onFollowSession,agentKind,+ agentDeviceId,modelValue,onChangeModel,effortValue,@@ -1060,9 +1064,10 @@ export function ModelEffortChip({fastMode,onChangeFast,}: {- onSelect: NonNullable<React.ComponentProps<typeof ModelSelectorContent>['onUnifiedSelect']>;+ onSelect: NonNullable<React.ComponentProps<typeof ModelRouteSelectorContent>['onUnifiedSelect']>;onFollowSession: () => void;agentKind: AgentKind;+ agentDeviceId?: string;modelValue: string;onChangeModel: (v: string) => void;effortValue: EffortValue | '';@@ -1109,12 +1114,14 @@ export function ModelEffortChip({},[disabled, discovery],);- const pickerAgents = useModelPickerAgents(agentKind);- const caps = useAgentCapabilities(agentKind);+ const pickerAgents = useModelPickerAgents(agentKind, agentDeviceId || undefined);+ const caps = useAgentCapabilities(agentKind, agentDeviceId || undefined);// 触发器(trigger)展示用:仍按 openai-codex/ 与 codex/ 折扣模型的 XD 网关来源可见性过滤,算出当前// 选中模型名。下拉内容本体改用聊天的 ModelSelectorContent(它内部按来源/api-key 自行// 过滤 + 分组),这里只为 trigger 文案保留最小化 model 解析。- const { providers, loading: providersLoading } = useProviders();+ const localProviders = useProviders();+ const remoteProviders = useDeviceProviders(agentDeviceId || undefined);+ const { providers, loading: providersLoading } = agentDeviceId ? remoteProviders : localProviders;const xdConnected = providers.some((p) => p.id === 'xd' && p.connected);const availableModels = caps.capabilities?.availableModels;const models = useMemo(@@ -1173,25 +1180,23 @@ export function ModelEffortChip({[providers, effectiveProviderId, effectiveId, agentKind],);const activeProvider = providers.find((p) => p.id === activeSourceId);+ const modelIcon = !isFollowingSession && (activeSourceId || agentDeviceId) ? (+ <ModelIconMark+ icon={activeProvider ? getModel(activeProvider, effectiveId, agentKind)?.icon : undefined}+ providerId={activeSourceId ?? providerId}+ name={activeProvider?.name}+ routing={activeProvider?.routing}+ logoKind={activeProvider?.logoKind}+ colorClass=""+ withMargin={false}+ />+ ) : undefined;return (<Popover open={open} onOpenChange={handleOpenChange}><PopoverTrigger asChild><ChipButton- icon={- !isFollowingSession && activeSourceId ? (- // 图标统一规则(与聊天 trigger 同口径):模型条目 icon(AI Gateway / 目录设定)- // 优先,缺省回落来源供应商标。- <ModelIconMark- icon={activeProvider ? getModel(activeProvider, effectiveId, agentKind)?.icon : undefined}- providerId={activeSourceId}- name={activeProvider?.name}- routing={activeProvider?.routing}- colorClass=""- withMargin={false}- />- ) : undefined- }+ icon={agentDeviceId && modelIcon ? <RemoteSourceMark>{modelIcon}</RemoteSourceMark> : modelIcon}label={display}active={open}disabled={disabled}@@ -1214,7 +1219,8 @@ export function ModelEffortChip({>{/* 直接复用聊天的下拉内容本体(唯一真源:聊天选择器改了这里跟着变)。来源轨 / 模型分组 / 搜索 / effort / 空态全套自带;followSession 行为 opt-in。 */}- <ModelSelectorContent+ <ModelRouteSelectorContent+ agentDeviceId={agentDeviceId || null}fastModeConfigurable={['codex', 'pi']}unifiedAgents={pickerAgents}onUnifiedSelect={onSelect}diff --git a/apps/desktop/src/renderer/features/scheduler/components/ScheduleFormDialog.tsx b/apps/desktop/src/renderer/features/scheduler/components/ScheduleFormDialog.tsxindex 5b415216db..1983616205 100644--- a/apps/desktop/src/renderer/features/scheduler/components/ScheduleFormDialog.tsx+++ b/apps/desktop/src/renderer/features/scheduler/components/ScheduleFormDialog.tsx@@ -14,6 +14,7 @@ import { Tip } from '@/components/ui/tooltip';import { Button } from '@/components/ui/button';import { useAgentCapabilities } from '@/hooks/useAgentCapabilities';import { useProviders } from '@/hooks/useProviders';+import { useDeviceProviders } from '@/hooks/useDeviceProviders';import {sessionModelSupportsFastMode,} from '@cindy/model-providers';@@ -134,8 +135,10 @@ export function ScheduleFormDialog({const { t } = useTranslation();const formApi = useScheduleForm(initial);const { form, setField, selectModelConfiguration, setDestination, setRunMode, selectBoundSession, applyTemplateAgentFields, reset, toInput, validate } = formApi;- const caps = useAgentCapabilities(form.agentKind);- const { providers, loading: providersLoading } = useProviders();+ const caps = useAgentCapabilities(form.agentKind, form.modelAgentDeviceId || undefined);+ const localProviders = useProviders();+ const remoteProviders = useDeviceProviders(form.modelAgentDeviceId || undefined);+ const { providers, loading: providersLoading } = form.modelAgentDeviceId ? remoteProviders : localProviders;// "运行会话"三态(fresh / persistent / bound)与心跳形态派生值。// hasRealBinding = targetSessionId 为真实会话 id(B 已绑 / C 已选 / MCP 手绑),// 此时目录 / worktree / fastMode 由绑定会话决定,表单隐藏对应字段。@@ -271,6 +274,7 @@ export function ScheduleFormDialog({description,scheduleName: form.name.trim() || undefined,providerId: providerId ?? undefined,+ modelAgentDeviceId: form.modelAgentDeviceId,// bound 任务的缺省模型/来源维度由 main 按绑定会话补齐;provider/model 的显式// 覆盖仍原样透传。persistent 任务即使已回写 targetSessionId,也按任务级选择生成。agentKind: resolveBoundSessionRoute ? undefined : form.agentKind,@@ -304,6 +308,7 @@ export function ScheduleFormDialog({providers,form.name,form.providerId,+ form.modelAgentDeviceId,form.effort,form.agentKind,form.model,@@ -1366,14 +1371,16 @@ export function ScheduleFormDialog({)}<div className="min-w-0 flex-1" /><ModelEffortChip- onSelect={({ engine, modelId, providerId, effort, fast }) => selectModelConfiguration({+ onSelect={({ engine, modelId, providerId, effort, fast, agentDevice }) => selectModelConfiguration({agentKind: engine === 'cc' ? 'claude-code' : engine,model: modelId, providerId, effort: (effort ?? '') as typeof form.effort,fastMode: fast,+ modelAgentDeviceId: agentDevice?.deviceId ?? '',})}onFollowSession={() => selectModelConfiguration(null,boundSessionReference?.agentKind === 'cc' ? 'claude-code' : boundSessionReference?.agentKind)}agentKind={form.agentKind}+ agentDeviceId={form.modelAgentDeviceId}modelValue={form.model}onChangeModel={(v) => setField('model', v)}effortValue={form.effort}diff --git a/apps/desktop/src/renderer/features/scheduler/components/__tests__/ScheduleChip.test.tsx b/apps/desktop/src/renderer/features/scheduler/components/__tests__/ScheduleChip.test.tsxindex ce9550066b..0aca2ec556 100644--- a/apps/desktop/src/renderer/features/scheduler/components/__tests__/ScheduleChip.test.tsx+++ b/apps/desktop/src/renderer/features/scheduler/components/__tests__/ScheduleChip.test.tsx@@ -6,6 +6,8 @@ import { afterEach, expect, it, vi } from 'vitest';vi.mock('react-i18next', () => ({useTranslation: () => ({ t: (key: string) => key, i18n: { language: 'en' } }),}));+// 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 --git a/apps/desktop/src/renderer/features/scheduler/hooks/useScheduleForm.ts b/apps/desktop/src/renderer/features/scheduler/hooks/useScheduleForm.tsindex 2f1900cfd2..272fdbcfa0 100644--- a/apps/desktop/src/renderer/features/scheduler/hooks/useScheduleForm.ts+++ b/apps/desktop/src/renderer/features/scheduler/hooks/useScheduleForm.ts@@ -262,6 +262,7 @@ export function makeFormFromSchedule(s: Schedule | null): ScheduleFormState {manual: s.manual,agentKind: s.modelAgentKind ?? s.agentKind,modelAgentKind: s.modelAgentKind,+ modelAgentDeviceId: s.modelAgentDeviceId,boundAgent: s.targetSessionId ? { sessionId: s.targetSessionId, agentKind: s.agentKind } : undefined,model: s.model ?? '',providerId: s.providerId ?? '',@@ -290,7 +291,7 @@ export type Destination = 'local' | 'worktree' | 'thread';export interface UseScheduleFormResult {form: ScheduleFormState;selectModelConfiguration: (- selection: Pick<ScheduleFormState, 'agentKind' | 'model' | 'providerId' | 'effort' | 'fastMode'> | null,+ selection: Pick<ScheduleFormState, 'agentKind' | 'model' | 'providerId' | 'effort' | 'fastMode' | 'modelAgentDeviceId'> | null,followedAgentKind?: ScheduleFormState['agentKind'],) => void;setField: <K extends keyof ScheduleFormState>(k: K, v: ScheduleFormState[K]) => void;@@ -351,7 +352,8 @@ export function useScheduleForm(initial: Schedule | null = null): UseScheduleFor? 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, modelAgentKind: undefined };+ return { ...form, agentKind, boundAgent, model: '', providerId: '', effort: '', fastMode: false,+ modelAgentKind: undefined, modelAgentDeviceId: undefined };});}, []);@@ -372,7 +374,8 @@ export function useScheduleForm(initial: Schedule | null = null): UseScheduleForgetAgentPrefs: 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 };+ return { ...f, ...selection, modelAgentKind: selection.model.trim() ? selection.agentKind : undefined,+ modelAgentDeviceId: template.model || template.agentKind || template.providerId ? '' : f.modelAgentDeviceId };});}, []);@@ -425,6 +428,7 @@ export function useScheduleForm(initial: Schedule | null = null): UseScheduleForboundAgent: { sessionId: session.id, agentKind: sessionAgentKindToScheduleAgentKind(session.agentKind) },model: '',modelAgentKind: undefined,+ modelAgentDeviceId: undefined,// 绑定会话 = 跟随其模型/来源,providerId 一并清空(与 model/effort 同语义)。providerId: '',effort: '',diff --git a/apps/desktop/src/renderer/features/scheduler/lib/__tests__/scheduleFormLogic.test.ts b/apps/desktop/src/renderer/features/scheduler/lib/__tests__/scheduleFormLogic.test.tsindex 24f18b1962..ed072037e1 100644--- 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,6 +441,19 @@ function makeTemplate(overrides: Partial<ScheduleTemplate> = {}): ScheduleTempla}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);+ 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);@@ -481,6 +494,28 @@ describe('buildScheduleInput — heartbeat 分支', () => {});describe('buildScheduleInput — 非 heartbeat 分支(行为锁定,不动 create 路径)', () => {+ // Unit regression: explicit choices must survive repeated remote/local saves+ // (model-selector-unified.md §3). Existing cases cover bound/script clearing,+ // but an unbound schedule kept remote effort when the local choice had none.+ // Minimal input: same Harness/model/provider, remote high -> local empty effort.+ it.each([false, true])('clears old effort across repeated source changes before binding (persistent=%s)', (persistentSession) => {+ let saved: Partial<ReturnType<typeof buildScheduleInput>> = {};+ const choices: Array<Pick<ScheduleFormState, 'modelAgentDeviceId' | 'effort' | 'fastMode'>> = [+ { modelAgentDeviceId: 'shared:owner', effort: 'xhigh', fastMode: 'ultrafast' },+ { modelAgentDeviceId: '', effort: '', fastMode: false },+ { modelAgentDeviceId: 'shared:owner', effort: 'low', fastMode: true },+ { modelAgentDeviceId: '', effort: '', fastMode: false },+ ];+ for (const choice of choices) {+ saved = { ...saved, ...buildScheduleInput(makeForm({+ agentKind: 'codex', modelAgentKind: 'codex', model: 'same-model', providerId: 'same-provider',+ persistentSession, ...choice,+ })) };+ expect(saved).toMatchObject({ ...choice, effort: choice.effort || undefined,+ model: 'same-model', providerId: 'same-provider', persistentSession });+ }+ });+it('空 model/effort 不带 key', () => {const input = buildScheduleInput(makeForm());expect(hasKey(input, 'model')).toBe(false);@@ -948,6 +983,25 @@ describe('scheduleToUserCreateInput', () => {describe('script lifecycle serialization', () => {+ // Review regression (unit): a script-mode patch previously cleared only the+ // location/Harness, reinterpreting a retained remote model as a local route.+ it.each([+ { modelAgentDeviceId: 'shared:owner', effort: 'xhigh' as const, fastMode: 'ultrafast' as const },+ { modelAgentDeviceId: '', effort: 'low' as const, fastMode: true },+ { modelAgentDeviceId: '', effort: '' as const, fastMode: false },+ ])('keeps the complete selected route when switching to script mode (%j)', (choice) => {+ const remote = { modelAgentKind: 'codex' as const, modelAgentDeviceId: 'shared:owner',+ model: 'same-model', providerId: 'openai', effort: 'xhigh', fastMode: 'ultrafast' as const };+ const selected = { ...remote, ...choice,+ ...(!choice.modelAgentDeviceId ? { model: 'local-model', providerId: 'local-provider' } : {}) };+ const form = makeForm({ ...selected, executionMode: 'script', scriptCommand: 'node run.mjs' });+ const merged = { ...remote, ...buildScheduleInput(form) };+ // An own undefined effort clears the previous value in a Desktop patch;+ // false must likewise clear a previously enabled Fast/Ultrafast mode.+ expect(merged).toMatchObject({ ...selected, effort: choice.effort || undefined });+ expect(merged.executionMode).toBe('script');+ expect(form).toMatchObject(selected);+ });it('preserves owner and installed gate while keeping script cwd', () => {const input = buildScheduleInput(makeForm({ executionMode: 'script',targetSessionId: 'owner', workingDir: '/watcher', scriptCommand: 'node run.mjs',diff --git a/apps/desktop/src/renderer/features/scheduler/lib/projectAutomationConfig.ts b/apps/desktop/src/renderer/features/scheduler/lib/projectAutomationConfig.tsindex 8a4a291be5..c203704adf 100644--- a/apps/desktop/src/renderer/features/scheduler/lib/projectAutomationConfig.ts+++ b/apps/desktop/src/renderer/features/scheduler/lib/projectAutomationConfig.ts@@ -17,6 +17,7 @@ export interface ProjectScheduleConfig {agentKind?: 'claude-code' | 'codex' | 'pi';/** 显式模型选择的 Harness;省略时保留旧配置的跟随绑定任务语义。 */modelAgentKind?: 'claude-code' | 'codex' | 'pi';+ modelAgentDeviceId?: string;model?: string;/** 显式来源(供应商)id;省略 = 使用该 Agent 的原生默认来源。 */providerId?: string;@@ -61,6 +62,7 @@ export function scheduleToProjectConfig(intervalMs: schedule.intervalMs,agentKind: schedule.agentKind,modelAgentKind: schedule.modelAgentKind,+ modelAgentDeviceId: schedule.modelAgentDeviceId,model: schedule.model,providerId: schedule.providerId || undefined,effort: schedule.effort,@@ -91,6 +93,7 @@ export function formToProjectConfig(intervalMs: 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,effort: form.effort || undefined,diff --git a/apps/desktop/src/renderer/features/scheduler/lib/scheduleFormLogic.ts b/apps/desktop/src/renderer/features/scheduler/lib/scheduleFormLogic.tsindex 8e9f4699fd..90fe0df90f 100644--- a/apps/desktop/src/renderer/features/scheduler/lib/scheduleFormLogic.ts+++ b/apps/desktop/src/renderer/features/scheduler/lib/scheduleFormLogic.ts@@ -140,6 +140,7 @@ export interface ScheduleFormState {manual: boolean;agentKind: 'claude-code' | 'codex' | 'pi';modelAgentKind?: 'claude-code' | 'codex' | 'pi';+ modelAgentDeviceId?: string;/** The bound task's baseline, independent of the editable model choice. Form-only. */boundAgent?: { sessionId: string; agentKind: ScheduleFormState['agentKind'] };model: string;@@ -298,6 +299,7 @@ export interface RememberedBinding {fastMode: boolean | 'ultrafast';agentKind: ScheduleFormState['agentKind'];modelAgentKind?: ScheduleFormState['modelAgentKind'];+ modelAgentDeviceId?: string;boundAgent?: ScheduleFormState['boundAgent'];}@@ -312,6 +314,7 @@ export function captureBinding(form: ScheduleFormState): RememberedBinding | nulfastMode: form.fastMode,agentKind: form.agentKind,modelAgentKind: form.modelAgentKind,+ modelAgentDeviceId: form.modelAgentDeviceId,boundAgent: form.boundAgent,};}@@ -347,6 +350,7 @@ export function applyRunMode(fastMode: remembered.fastMode,agentKind: remembered.agentKind,modelAgentKind: remembered.modelAgentKind,+ modelAgentDeviceId: remembered.modelAgentDeviceId,boundAgent: remembered.boundAgent,}: f;@@ -566,6 +570,7 @@ export function buildScheduleInput(form: ScheduleFormState): CreateScheduleInputintervalMs: form.intervalMs,agentKind: scheduleAgentKindForForm(form),modelAgentKind: !isScript && form.model.trim() ? form.modelAgentKind : undefined,+ modelAgentDeviceId: !isScript && form.model.trim() ? form.modelAgentDeviceId : undefined,workspaceKind: form.workspaceKind,useWorktree: !isScript && form.workspaceKind === 'project' && form.useWorktree,persistentSession: !isScript && form.persistentSession,@@ -583,6 +588,16 @@ export function buildScheduleInput(form: ScheduleFormState): CreateScheduleInputbase.workspaceKind = 'project';base.workingDir = form.workingDir.trim();base.useWorktree = false;+ // Preserve the complete route so host validation rejects the unsupported+ // combination without silently turning a remote provider into a local one.+ if (form.modelAgentDeviceId !== undefined) {+ base.modelAgentDeviceId = form.modelAgentDeviceId;+ base.modelAgentKind = form.modelAgentKind;+ base.model = form.model.trim();+ base.providerId = form.providerId.trim();+ base.effort = form.effort && isEffortValue(form.effort) ? form.effort : undefined;+ base.fastMode = form.fastMode;+ }// Preserve installed script gates when editing; hidden controls must not erase them.return base;}@@ -603,6 +618,9 @@ export function buildScheduleInput(form: ScheduleFormState): CreateScheduleInput// 让 update patch 按「key 在 + undefined」把旧 provider_id 清成 NULL。base.providerId = form.providerId.trim() || undefined;if (form.effort && isEffortValue(form.effort)) base.effort = form.effort;+ // An explicit model choice replaces all its axes, including no effort. Keep+ // the own key so updating an unbound automation clears the previous route's tier.+ else if (form.modelAgentKind && form.model.trim()) base.effort = undefined;// fastMode 对 Codex / Pi 都生效(runner.ts:665 明确 claude-code 忽略此字段);只序列化// codex 会让用户在 Pi 任务里开的 Fast 被静默丢弃(codex review)。表单侧 Fast 开关已按// capability × 模型 supportsFastMode 门控,Pi 只有真支持时才可能为 true。@@ -626,6 +644,7 @@ export function scheduleToUserCreateInput(intervalMs: schedule.intervalMs,agentKind: schedule.modelAgentKind ?? schedule.agentKind,modelAgentKind: schedule.modelAgentKind,+ modelAgentDeviceId: schedule.modelAgentDeviceId,model: schedule.model,providerId: schedule.providerId,fastMode: schedule.fastMode,diff --git a/apps/desktop/src/renderer/vite-env.d.ts b/apps/desktop/src/renderer/vite-env.d.tsindex 732ccc0aa6..4407526f89 100644--- a/apps/desktop/src/renderer/vite-env.d.ts+++ b/apps/desktop/src/renderer/vite-env.d.ts@@ -7226,6 +7226,7 @@ interface ElectronAPI {scheduleName?: string;workingDir?: string;providerId?: string;+ modelAgentDeviceId?: string;agentKind?: 'claude-code' | 'codex' | 'pi';model?: string;/** 绑定会话任务:workingDir 空时 main 按会话 meta.workDir 解析落盘/自测目录。 */diff --git a/apps/desktop/src/shared/scheduledModelBaseline.ts b/apps/desktop/src/shared/scheduledModelBaseline.tsindex d3d128c509..ce5fe9199e 100644--- a/apps/desktop/src/shared/scheduledModelBaseline.ts+++ b/apps/desktop/src/shared/scheduledModelBaseline.ts@@ -4,6 +4,7 @@ import type { MakerAgentKindWire } from './agentKindConversion';export interface ScheduledModelBaseline {scopeId: string;agentKind: MakerAgentKindWire;+ agentDeviceId?: string | null;model: string;providerId: string | null;effort: 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'ultra' | null;@@ -20,6 +21,7 @@ export function parseScheduledModelBaseline(value: unknown): ScheduledModelBaselconst effort = parsed?.effort === '' ? null : parsed?.effort;if (!parsed || typeof parsed.scopeId !== 'string' ||!['claude-code', 'codex', 'pi'].includes(parsed.agentKind) ||+ (parsed.agentDeviceId !== undefined && parsed.agentDeviceId !== null && typeof parsed.agentDeviceId !== 'string') ||typeof parsed.model !== 'string' || !parsed.model ||(parsed.providerId !== null && typeof parsed.providerId !== 'string') ||(effort !== null && !['minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'ultra'].includes(effort)) ||diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.mdindex 43bb327b6d..ad87f339c9 100644--- a/docs/dev-rules/protocol-compatibility.md+++ b/docs/dev-rules/protocol-compatibility.md@@ -3071,3 +3071,13 @@ namespace + id 下同一插件的有界 JSON 请求;`deviceSync: true` 是独配置读取、保存与包内导航照旧,完整跨文档确认隔离须两端都更新。插件本身无需更新,不改变已装批准、凭证、KV、版本或原生指纹。实现与时序验证见[原配置页协议](../remote-plugin-oauth.md#手机原配置页授权的增量能力)。++## 自动化的远程模型选择++`Schedule` / 创建与更新输入增量增加可选 `modelAgentDeviceId`:缺省保持旧版绑定任务的位置继承,+空字符串表示自动化所在电脑,非空使用既有远程/分享 Agent 标识。SQLite 新增可空文本列,+SQL NULL 对应缺省;项目 `version: 1` 配置同样允许该字段,旧文件无需改写。+`maker:get-capabilities` 返回 `supportsScheduleAgentDeviceSelection: true`。+新调用方只有明确看到此能力才向其它电脑提交位置选择;旧端未知字段会被忽略,禁止静默降级。+旧调用方修改新自动化的非模型字段仍保留位置;修改模型路线却未携带已固定的位置时拒绝保存,+避免意外把另一台电脑的供应商当作本机来源。执行与恢复仍使用既有远程授权、目录与切换协议。diff --git a/docs/product-rules/agent-user-parity.md b/docs/product-rules/agent-user-parity.mdindex 1c3e020a13..fb956037b2 100644--- a/docs/product-rules/agent-user-parity.md+++ b/docs/product-rules/agent-user-parity.md@@ -52,6 +52,7 @@| 协同 / Worker | 为 Worker 新建 worktree、指定源分支、归档时回收 | 有 | 无 || 定时任务 | 列出、详情、运行记录、修改、暂停、恢复、删除、立即运行 | 有 | 有(2026-10-14) || 定时任务 | 新建、安装检查脚本 | 有 | 无 |+| 定时任务 | 选择远程/分享供应商模型(运行位置、引擎、模型与速度) | 有 | 有(目标电脑须支持 `supportsScheduleAgentDeviceSelection`) || 定时任务 | 删除单条运行记录、标记已读 | 无 | 无 || 项目 | 列出、登记、改名、移除;工作目录列表 | 有 | 无 || 伙伴 | 发现伙伴、伙伴间消息 | 有 | 有 |diff --git a/docs/product-rules/model-selector-unified.md b/docs/product-rules/model-selector-unified.mdindex 78f4ac32ff..3800800739 100644--- a/docs/product-rules/model-selector-unified.md+++ b/docs/product-rules/model-selector-unified.md@@ -209,6 +209,19 @@项目自动化的 `schedules.json` 同样保存可选的 `modelAgentKind`,导出、加载与配置同步均保留该标记;删除标记时清除数据库中的覆盖,已有绑定任务不丢失。旧版 `version: 1` 文件无需补字段。自动触发前按实际来源、Harness 和模型的当前目录拷贝补齐或收敛 effort,并清除已不受支持的 Fast;仍有效的用户选择保持不变。+自动化复用统一选择器的远程电脑与分享供应商列表、来源标识及图标。可选 `modelAgentDeviceId`+保存所选 Agent 位置:缺省沿用绑定任务(新建时为本机),空字符串明确选择自动化所在电脑,+非空为既有远程/分享来源 id。只修改后续触发的配置,不改历史记录、不打断当前运行;+新建、持续与绑定模式保持不变。绑定任务执行后的恢复记录同时保存原 Agent 位置。+工作目录、文件、Skill 与插件仍走自动化所在电脑的既有远程 Agent 通道与权限,不借用分享方配置。+Desktop 的 `ModelRouteSelector` 提供完整控件,`ModelRouteSelectorContent` 提供嵌入既有弹层的面板;+两者共用位置候选接入。自动化使用后者,保留自身按钮、跟随选项与保存时机,不另行拼装远程来源。+两种形式均透传统一选择器的完整选模结果;专用能力限制仍由调用场景声明。+前置检查脚本的 AI 生成使用直接 utility HTTP 接口,暂不支持远程来源,明确返回不支持的传输方式;+不得误用本机同名供应商。已有脚本的执行不受影响。+“仅运行脚本”模式暂不支持远程模型来源;切换保存时保留完整来源并明确拒绝,原配置不变,+先选回本机模型后可切换。脚本的 `sessions.dispatch` 新建任务同样不得将远程配置解释成本机来源。+---## 4. 特殊情况检查表(实现与 review 逐条过)diff --git a/packages/lizi-mcps/src/__tests__/cindy_schedulerMcpServer.test.ts b/packages/lizi-mcps/src/__tests__/cindy_schedulerMcpServer.test.tsindex 46382b75d4..bdb34c121a 100644--- a/packages/lizi-mcps/src/__tests__/cindy_schedulerMcpServer.test.ts+++ b/packages/lizi-mcps/src/__tests__/cindy_schedulerMcpServer.test.ts@@ -221,6 +221,26 @@ describe('cindy_scheduler MCP server (in-process smoke)', () => {h = await makeHarness();});+ // Integration: schema parsing used to strip the Agent location. Follow the real+ // MCP dispatcher through create/update and verify the saved route and null clear.+ it('persists shared model selections and clears their location through MCP', async () => {+ try {+ const route = { modelAgentKind: 'codex', modelAgentDeviceId: 'shared:owner',+ model: 'shared-model', providerId: 'remote-provider', fastMode: 'ultrafast' };+ const result = await h.client.callTool({ name: 'call_tool', arguments: {+ name: 'schedule_create', args: { ...baseCreate, ...route },+ } });+ expect(result.isError).not.toBe(true);+ const [created] = await h.storage.list();+ expect(created).toMatchObject(route);+ const updated = await h.client.callTool({ name: 'call_tool', arguments: {+ name: 'schedule_update', args: { id: created.id, modelAgentDeviceId: null },+ } });+ expect(updated.isError).not.toBe(true);+ expect(await h.storage.get(created.id)).toMatchObject({ ...route, modelAgentDeviceId: undefined });+ } finally { await h.cleanup(); }+ });+it('list_tools without category returns the scheduler category', async () => {const result = await h.client.callTool({ name: 'list_tools', arguments: {} });const first = (result.content as Array<{ type: string; text: string }>)[0];diff --git a/packages/lizi-mcps/src/cindy_schedulerMcpServer.ts b/packages/lizi-mcps/src/cindy_schedulerMcpServer.tsindex 76695ffae7..261f142bcc 100644--- a/packages/lizi-mcps/src/cindy_schedulerMcpServer.ts+++ b/packages/lizi-mcps/src/cindy_schedulerMcpServer.ts@@ -89,7 +89,7 @@ const CATEGORY_ENUM = ['scheduler'] as const;/** 类目概览的一句话用途 + 作用范围(本机 / 可跨电脑);改工具作用范围时同步改这里。 */export const SCHEDULER_CATEGORY_DESCRIPTIONS: Record<(typeof CATEGORY_ENUM)[number], string> = {scheduler:- '定时任务(自动化 / 心跳)的查询与管理。定时任务保存在各自的电脑上:查询、修改、暂停、恢复、删除、立即运行可指定电脑(device,查询可传 all);新建、检查脚本安装、当前运行的通知设置只在本机。',+ '定时任务(自动化 / 心跳)的查询与管理,模型可选本机、远程或分享供应商。定时任务保存在各自的电脑上:查询、修改、暂停、恢复、删除、立即运行可指定电脑(device,查询可传 all);新建、检查脚本安装、当前运行的通知设置只在本机。',};function registerListToolsEntry(diff --git a/packages/lizi-mcps/src/scheduler/create.ts b/packages/lizi-mcps/src/scheduler/create.tsindex 7d264e28a2..8842d11135 100644--- a/packages/lizi-mcps/src/scheduler/create.ts+++ b/packages/lizi-mcps/src/scheduler/create.ts@@ -90,6 +90,9 @@ export function registerScheduleCreateTool(.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;工作目录和工具仍属于自动化所在电脑'),kind: z.literal('cron').default('cron')diff --git a/packages/lizi-mcps/src/scheduler/update.ts b/packages/lizi-mcps/src/scheduler/update.tsindex 0b1639e171..270196f1cb 100644--- a/packages/lizi-mcps/src/scheduler/update.ts+++ b/packages/lizi-mcps/src/scheduler/update.ts@@ -40,6 +40,9 @@ export function registerScheduleUpdateTool(timezone: 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'),kind: z.literal('cron').optional(),model: z.string()@@ -184,7 +187,7 @@ export function registerScheduleUpdateTool(// undefined(storage 按 hasOwnProperty 判定 → 清列 NULL)。此前 schema 只收// string,agent 想把任务从一个引擎的模型路由上摘下来(如伙伴接管期用 Codex// 模型跑过、再改回 Claude Code)只能报 INVALID_ARGS,陈旧路由永远清不掉。- 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 --git a/packages/maker-scheduler/src/__tests__/scheduler.test.ts b/packages/maker-scheduler/src/__tests__/scheduler.test.tsindex aa38575c22..df4a0cf6b8 100644--- a/packages/maker-scheduler/src/__tests__/scheduler.test.ts+++ b/packages/maker-scheduler/src/__tests__/scheduler.test.ts@@ -225,6 +225,62 @@ 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');+ 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 (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@@ -578,6 +634,24 @@ describe('Scheduler', () => {).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 });+ 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 --git a/packages/maker-scheduler/src/engine/scheduler.ts b/packages/maker-scheduler/src/engine/scheduler.tsindex d18d506262..c68abf11ac 100644--- a/packages/maker-scheduler/src/engine/scheduler.ts+++ b/packages/maker-scheduler/src/engine/scheduler.ts@@ -56,9 +56,14 @@ function normalizeScriptConfig(}function validateScheduleExecutionShape(- schedule: Pick<Schedule, 'executionMode' | 'scriptConfig' | 'workspaceKind' | 'workingDir' | 'useWorktree' | 'targetSessionId' | 'persistentSession' | 'prompt' | 'silentWhenIdle' | 'modelAgentKind' | 'model'>,+ schedule: Pick<Schedule, 'executionMode' | 'scriptConfig' | 'workspaceKind' | 'workingDir' | 'useWorktree' | 'targetSessionId' | 'persistentSession' | 'prompt' | 'silentWhenIdle' | 'modelAgentKind' | 'modelAgentDeviceId' | 'model' | 'providerId'>,opts: { checkAgentPrompt: boolean } = { checkAgentPrompt: true },): void {+ 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');@@ -74,6 +79,9 @@ function validateScheduleExecutionShape(}return;}+ if (schedule.modelAgentDeviceId) {+ throw new Error('script execution does not support remote model sources; select a local model before switching modes');+ }if (!schedule.scriptConfig?.command.trim()) {throw new Error('script execution requires a non-empty command');}@@ -111,7 +119,7 @@ export interface SchedulerOptions {validateTargetSession?: (targetSessionId: string,operation: 'create' | 'update' | 'fire',- selection: Pick<Schedule, 'modelAgentKind'>,+ selection: Pick<Schedule, 'modelAgentKind' | 'modelAgentDeviceId'>,) => Promise<void>;/*** 被动模式:本实例不参与自动触发 —— start() 不装 tick 时钟、不做僵尸 run 清理@@ -1384,6 +1392,13 @@ export class Scheduler extends EventEmitter {}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(+ (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 --git a/packages/maker-scheduler/src/types.ts b/packages/maker-scheduler/src/types.tsindex 5cb37ceacb..8fd880ac60 100644--- a/packages/maker-scheduler/src/types.ts+++ b/packages/maker-scheduler/src/types.ts@@ -217,6 +217,8 @@ export interface Schedule {agentKind: AgentKind;/** Explicit model-picker Harness. Absent on legacy schedules: bound tasks keep their live Harness. */modelAgentKind?: AgentKind;+ /** Agent location for an explicit model choice: absent = inherit the bound task; '' = task host. */+ modelAgentDeviceId?: string;model?: string;/*** 显式选定的供应商(来源)id。undefined / 空 → 回落该 agent 原生默认来源@@ -353,6 +355,8 @@ export interface CreateScheduleInput {agentKind: AgentKind;/** Explicit model-picker Harness. Absent on legacy schedules: bound tasks keep their live Harness. */modelAgentKind?: AgentKind;+ /** Agent location for an explicit model choice: absent = inherit the bound task; '' = task host. */+ modelAgentDeviceId?: string;model?: string;/*** 显式选定的供应商(来源)id。undefined / 空 → 回落该 agent 原生默认来源diff --git a/packages/maker-shared/src/__tests__/scheduleForm.test.ts b/packages/maker-shared/src/__tests__/scheduleForm.test.tsindex b03a60bebb..72b8f81b1b 100644--- a/packages/maker-shared/src/__tests__/scheduleForm.test.ts+++ b/packages/maker-shared/src/__tests__/scheduleForm.test.ts@@ -369,6 +369,29 @@ describe('mobile schedule form model', () => {expect(input.targetSessionId).toBe('sess-oops');});+ // Unit regression: mobile edits must retain the complete unsupported route+ // for host validation, instead of dropping only its remote location.+ it.each([+ { modelAgentDeviceId: 'shared:owner', effort: 'xhigh', fastMode: 'ultrafast' as const },+ { modelAgentDeviceId: '', effort: 'low', fastMode: true },+ { modelAgentDeviceId: '', effort: '', fastMode: false },+ ])('preserves complete script routes across mobile edits (%j)', (choice) => {+ const remote = {+ modelAgentKind: 'codex' as const,+ modelAgentDeviceId: 'shared:owner',+ model: 'same-model',+ providerId: 'openai',+ effort: 'xhigh' as const,+ fastMode: 'ultrafast' as const,+ };+ const draft = createMobileScheduleDraft(schedule({ executionMode: 'script', ...remote }));+ const selected = { ...remote, ...choice,+ ...(!choice.modelAgentDeviceId ? { model: 'local-model', providerId: 'local-provider' } : {}) };+ // Empty effort and false Fast must survive JSON transport to clear old values.+ const wire = JSON.parse(JSON.stringify(buildMobileScheduleInput({ ...draft, ...selected, name: 'Renamed' })));+ expect({ ...remote, ...wire }).toMatchObject(selected);+ });+it('still requires a prompt for a regular agent-mode schedule', () => {const draft = createMobileScheduleDraft(schedule({ prompt: '' }));expect(validateMobileScheduleDraft(draft)).toMatchObject({ field: 'prompt' });@@ -594,6 +617,18 @@ describe('mobile explicit Harness round-trip', () => {describe('mixed-version scheduled model selections', () => {+ // Unit: JSON round trips retain the location; an old host must not accept+ // a shared selection and silently create it with its own local credentials.+ it.each(['', 'shared:owner'])('preserves location %j and requires peer support', (modelAgentDeviceId) => {+ const draft = createMobileScheduleDraft(schedule({ modelAgentKind: 'pi', agentKind: 'pi',+ model: 'remote-model', providerId: 'remote-provider', modelAgentDeviceId }));+ const input = buildMobileScheduleInput(draft);+ expect(JSON.parse(JSON.stringify(input)).modelAgentDeviceId).toBe(modelAgentDeviceId);+ const compat = { supportsIntervalNullClear: true, supportsModelSelection: true };+ expect(() => applyScheduleWireCompat(input, compat)).toThrow(ScheduleModelSelectionUnsupportedError);+ expect(applyScheduleWireCompat(input, { ...compat, supportsAgentDeviceSelection: true })).toBe(input);+ expect(buildMobileScheduleInput({ ...draft, model: '' }).modelAgentDeviceId).toBe('');+ });it.each([null, 600_000])('rejects an explicit bound selection on old/unknown hosts with interval %s', (intervalMs) => {const input = { ...buildMobileScheduleInput(createMobileScheduleDraft(schedule())),targetSessionId: 'bound', modelAgentKind: 'pi' as const, agentKind: 'pi' as const,diff --git a/packages/maker-shared/src/scheduleForm.ts b/packages/maker-shared/src/scheduleForm.tsindex a1b33089a4..a219484da3 100644--- a/packages/maker-shared/src/scheduleForm.ts+++ b/packages/maker-shared/src/scheduleForm.ts@@ -57,6 +57,7 @@ export interface MobileScheduleDraft {intervalMinutesTouched?: boolean;agentKind: RemoteScheduleAgentKind;modelAgentKind?: RemoteScheduleAgentKind;+ modelAgentDeviceId?: string;/** Form-only baseline; changing the selected model must not overwrite this binding. */boundAgent?: { sessionId: string; agentKind: RemoteScheduleAgentKind };model: string;@@ -176,6 +177,7 @@ export function createMobileScheduleDraft(...(typeof schedule.intervalMs === 'number' ? { sourceIntervalMs: schedule.intervalMs } : {}),agentKind: schedule.modelAgentKind ?? schedule.agentKind ?? 'claude-code',modelAgentKind: schedule.modelAgentKind,+ modelAgentDeviceId: schedule.modelAgentDeviceId,boundAgent: schedule.targetSessionId? { sessionId: schedule.targetSessionId, agentKind: schedule.agentKind ?? 'claude-code' } : undefined,model: schedule.model ?? '',@@ -225,6 +227,8 @@ export function applyTemplateToMobileScheduleDraft(agentKind,// A template producing a model is an explicit choice, including a legacy bound draft....(model.trim() || draft.modelAgentKind ? { modelAgentKind: agentKind } : {}),+ modelAgentDeviceId: template.model || template.agentKind || template.providerId+ ? (draft.modelAgentDeviceId === undefined ? undefined : '') : draft.modelAgentDeviceId,model,// 模板若固定了 provider,必须随模板一起落到新建任务;否则 Pi 的空模型会在// host 侧按错误的默认来源解析。模板未指定时才保留同 agent 的用户选择。@@ -430,6 +434,15 @@ export function buildMobileScheduleInput(draft: MobileScheduleDraft): RemoteScheif (draft.executionMode === 'script') {// Script schedules retain their lifecycle owner when edited from mobile.// They still run in their own project cwd without starting an agent turn.+ // Keep an unsupported remote route whole for host validation.+ if (draft.modelAgentDeviceId !== undefined) {+ input.modelAgentDeviceId = draft.modelAgentDeviceId;+ input.modelAgentKind = draft.modelAgentKind;+ input.model = draft.model.trim();+ input.providerId = draft.providerId.trim();+ input.effort = draft.effort.trim();+ input.fastMode = draft.fastMode;+ }return {...input,workspaceKind: 'project',@@ -443,6 +456,9 @@ export function buildMobileScheduleInput(draft: MobileScheduleDraft): RemoteSche// An empty model follows the bound task. Omit the marker so the full-form// device-link normalization can clear an existing explicit selection.+ if (draft.modelAgentDeviceId !== undefined) {+ input.modelAgentDeviceId = draft.model.trim() ? draft.modelAgentDeviceId : '';+ }if (draft.modelAgentKind && draft.model.trim()) {input.modelAgentKind = draft.agentKind;input.model = draft.model.trim();@@ -492,8 +508,11 @@ export class SchedulePreRunHookUnsupportedError extends Error {}*/export function applyScheduleWireCompat(input: RemoteScheduleWriteInput,- opts: { supportsIntervalNullClear: boolean; supportsModelSelection?: boolean; supportsPreRunHook?: boolean },+ opts: { supportsIntervalNullClear: boolean; supportsModelSelection?: boolean; supportsPreRunHook?: boolean; supportsAgentDeviceSelection?: boolean },): RemoteScheduleWriteInput {+ if (input.modelAgentDeviceId !== undefined && !opts.supportsAgentDeviceSelection) {+ throw new ScheduleModelSelectionUnsupportedError('Scheduled Agent location selection requires a newer desktop');+ }if (!opts.supportsPreRunHook && input.preRunHook !== undefined) {// An old host can acknowledge the save while silently dropping this field.// Reject both installation and removal instead of claiming either succeeded.@@ -524,6 +543,7 @@ export function updateDraftAgentKind(agentKind,// Selecting another Harness must leave follow mode even on pre-upgrade bindings....(draft.modelAgentKind || draft.targetSessionId.trim() ? { modelAgentKind: agentKind } : {}),+ modelAgentDeviceId: draft.modelAgentDeviceId === undefined ? undefined : '',model: '',providerId: '',effort: '',diff --git a/packages/maker-shared/src/scheduleTypes.ts b/packages/maker-shared/src/scheduleTypes.tsindex 00e14d786e..05c27193ce 100644--- a/packages/maker-shared/src/scheduleTypes.ts+++ b/packages/maker-shared/src/scheduleTypes.ts@@ -31,6 +31,8 @@ export interface RemoteScheduleWriteInput {intervalMs?: number | null;agentKind: RemoteScheduleAgentKind;modelAgentKind?: RemoteScheduleAgentKind;+ /** Absent = inherit bound task; empty string = automation host. */+ modelAgentDeviceId?: string;model?: string;providerId?: string;effort?: string;@@ -103,6 +105,8 @@ export interface RemoteSchedule {intervalMs?: number;agentKind?: RemoteScheduleAgentKind;modelAgentKind?: RemoteScheduleAgentKind;+ /** Absent = inherit bound task; empty string = automation host. */+ modelAgentDeviceId?: string;model?: string;providerId?: string;effort?: string;