Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(orca): 运行设备承接另一台电脑派来的协同 Worker
DavidShen5d84f1a482d9
diff --git a/apps/desktop/drizzle/0124_funny_glorian.sql b/apps/desktop/drizzle/0124_funny_glorian.sqlnew file mode 100644index 0000000000..e0ac49d1ec--- /dev/null+++ b/apps/desktop/drizzle/0124_funny_glorian.sql@@ -0,0 +1 @@+SELECT 1;diff --git a/apps/desktop/drizzle/meta/0124_snapshot.json b/apps/desktop/drizzle/meta/0124_snapshot.jsonnew file mode 100644index 0000000000..828fbdaaa4--- /dev/null+++ b/apps/desktop/drizzle/meta/0124_snapshot.json@@ -0,0 +1,6885 @@+{+ "version": "6",+ "dialect": "sqlite",+ "id": "86f88929-384d-4831-bf8e-a29b3d83ec85",+ "prevId": "d06b22f6-84f0-4f67-b5ab-0f13f2e21a2a",+ "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": "'{}'"+ },+ "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_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+ },+ "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": {}+ },+ "project_aliases": {+ "name": "project_aliases",+ "columns": {+ "project_key": {+ "name": "project_key",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "alias": {+ "name": "alias",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "idx_project_aliases_updated_at": {+ "name": "idx_project_aliases_updated_at",+ "columns": [+ "updated_at"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "project_automation_consents": {+ "name": "project_automation_consents",+ "columns": {+ "working_dir": {+ "name": "working_dir",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "consented_at": {+ "name": "consented_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "config_hash": {+ "name": "config_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "recent_workdirs": {+ "name": "recent_workdirs",+ "columns": {+ "path": {+ "name": "path",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "last_used_at": {+ "name": "last_used_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "idx_recent_workdirs_last_used_at": {+ "name": "idx_recent_workdirs_last_used_at",+ "columns": [+ "last_used_at"+ ],+ "isUnique": false+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "right_sidebar_tabs": {+ "name": "right_sidebar_tabs",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "is_active": {+ "name": "is_active",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "state": {+ "name": "state",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'{}'"+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "right_sidebar_tabs_session_idx": {+ "name": "right_sidebar_tabs_session_idx",+ "columns": [+ "session_id",+ "position"+ ],+ "isUnique": false+ },+ "right_sidebar_tabs_subagents_singleton_idx": {+ "name": "right_sidebar_tabs_subagents_singleton_idx",+ "columns": [+ "session_id"+ ],+ "isUnique": true,+ "where": "\"right_sidebar_tabs\".\"kind\" = 'subagents'"+ },+ "right_sidebar_tabs_bot_artifacts_singleton_idx": {+ "name": "right_sidebar_tabs_bot_artifacts_singleton_idx",+ "columns": [+ "session_id"+ ],+ "isUnique": true,+ "where": "\"right_sidebar_tabs\".\"kind\" = 'bot-artifacts'"+ }+ },+ "foreignKeys": {+ "right_sidebar_tabs_session_id_sessions_id_fk": {+ "name": "right_sidebar_tabs_session_id_sessions_id_fk",+ "tableFrom": "right_sidebar_tabs",+ "tableTo": "sessions",+ "columnsFrom": [+ "session_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "schedule_runs": {+ "name": "schedule_runs",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "schedule_id": {+ "name": "schedule_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "fired_at": {+ "name": "fired_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "finished_at": {+ "name": "finished_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "error_msg": {+ "name": "error_msg",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "cost_usd": {+ "name": "cost_usd",+ "type": "real",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "estimated_value_usd": {+ "name": "estimated_value_usd",+ "type": "real",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "cost_amount": {+ "name": "cost_amount",+ "type": "real",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "estimated_value_amount": {+ "name": "estimated_value_amount",+ "type": "real",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "cost_currency": {+ "name": "cost_currency",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "cost_is_approximate": {+ "name": "cost_is_approximate",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "cost_attribution": {+ "name": "cost_attribution",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'legacy'"+ },+ "result_text": {+ "name": "result_text",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "pre_run_hook_result": {+ "name": "pre_run_hook_result",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "read_at": {+ "name": "read_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "heartbeat_at": {+ "name": "heartbeat_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ }+ },+ "indexes": {+ "idx_schedule_runs_schedule": {+ "name": "idx_schedule_runs_schedule",+ "columns": [+ "schedule_id",+ "fired_at"+ ],+ "isUnique": false+ },+ "idx_schedule_runs_running_schedule": {+ "name": "idx_schedule_runs_running_schedule",+ "columns": [+ "schedule_id"+ ],+ "isUnique": false,+ "where": "\"schedule_runs\".\"status\" = 'running'"+ },+ "idx_schedule_runs_running_heartbeat": {+ "name": "idx_schedule_runs_running_heartbeat",+ "columns": [+ "heartbeat_at"+ ],+ "isUnique": false,+ "where": "\"schedule_runs\".\"status\" = 'running' AND \"schedule_runs\".\"heartbeat_at\" IS NOT NULL"+ },+ "idx_schedule_runs_running_legacy": {+ "name": "idx_schedule_runs_running_legacy",+ "columns": [+ "fired_at"+ ],+ "isUnique": false,+ "where": "\"schedule_runs\".\"status\" = 'running' AND \"schedule_runs\".\"heartbeat_at\" IS NULL"+ },+ "idx_schedule_runs_unread_terminal": {+ "name": "idx_schedule_runs_unread_terminal",+ "columns": [+ "schedule_id",+ "status",+ "fired_at"+ ],+ "isUnique": false,+ "where": "\"schedule_runs\".\"read_at\" IS NULL AND \"schedule_runs\".\"status\" IN ('success', 'failed', 'aborted', 'interrupted')"+ },+ "idx_schedule_runs_session_latest": {+ "name": "idx_schedule_runs_session_latest",+ "columns": [+ "session_id",+ "fired_at",+ "id"+ ],+ "isUnique": false,+ "where": "\"schedule_runs\".\"session_id\" IS NOT NULL"+ }+ },+ "foreignKeys": {+ "schedule_runs_schedule_id_schedules_id_fk": {+ "name": "schedule_runs_schedule_id_schedules_id_fk",+ "tableFrom": "schedule_runs",+ "tableTo": "schedules",+ "columnsFrom": [+ "schedule_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "schedule_runs_session_id_sessions_id_fk": {+ "name": "schedule_runs_session_id_sessions_id_fk",+ "tableFrom": "schedule_runs",+ "tableTo": "sessions",+ "columnsFrom": [+ "session_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "schedule_session_latest_runs": {+ "name": "schedule_session_latest_runs",+ "columns": {+ "session_id": {+ "name": "session_id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "run_id": {+ "name": "run_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "fired_at": {+ "name": "fired_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ }+ },+ "indexes": {+ "idx_schedule_session_latest_runs_run": {+ "name": "idx_schedule_session_latest_runs_run",+ "columns": [+ "run_id"+ ],+ "isUnique": true+ }+ },+ "foreignKeys": {+ "schedule_session_latest_runs_session_id_sessions_id_fk": {+ "name": "schedule_session_latest_runs_session_id_sessions_id_fk",+ "tableFrom": "schedule_session_latest_runs",+ "tableTo": "sessions",+ "columnsFrom": [+ "session_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "schedule_session_latest_runs_run_id_schedule_runs_id_fk": {+ "name": "schedule_session_latest_runs_run_id_schedule_runs_id_fk",+ "tableFrom": "schedule_session_latest_runs",+ "tableTo": "schedule_runs",+ "columnsFrom": [+ "run_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "schedules": {+ "name": "schedules",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "prompt": {+ "name": "prompt",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "job_type": {+ "name": "job_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'prompt'"+ },+ "job_config": {+ "name": "job_config",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "execution_mode": {+ "name": "execution_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'agent'"+ },+ "script_config": {+ "name": "script_config",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false,+ "default": "'user'"+ },+ "project_config_id": {+ "name": "project_config_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "legacy_session_fallback": {+ "name": "legacy_session_fallback",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'cron'"+ },+ "cron_expr": {+ "name": "cron_expr",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "timezone": {+ "name": "timezone",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "recurring": {+ "name": "recurring",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": true+ },+ "manual": {+ "name": "manual",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "interval_ms": {+ "name": "interval_ms",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "agent_kind": {+ "name": "agent_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "model_agent_kind": {+ "name": "model_agent_kind",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "provider_id": {+ "name": "provider_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "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'"+ },+ "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+ },+ "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 8bb39609fd..b15111d828 100644--- a/apps/desktop/drizzle/meta/_journal.json+++ b/apps/desktop/drizzle/meta/_journal.json@@ -869,6 +869,13 @@"when": 1791260458468,"tag": "0123_wonderful_oracle","breakpoints": true+ },+ {+ "idx": 124,+ "version": "6",+ "when": 1791526759742,+ "tag": "0124_funny_glorian",+ "breakpoints": true}]}\ No newline at end of filediff --git a/apps/desktop/drizzle/scripts/0124_funny_glorian.ts b/apps/desktop/drizzle/scripts/0124_funny_glorian.tsnew file mode 100644index 0000000000..8352f0f7ac--- /dev/null+++ b/apps/desktop/drizzle/scripts/0124_funny_glorian.ts@@ -0,0 +1,34 @@+import type Database from 'better-sqlite3';++function columnNames(db: Database.Database, tableName: string): Set<string> {+ return new Set(+ db+ .prepare(`PRAGMA table_info('${tableName}')`)+ .all()+ .map((row) => String((row as { name: unknown }).name)),+ );+}++function addMissingColumns(+ db: Database.Database,+ tableName: string,+ columns: Array<[string, string]>,+): void {+ const existing = columnNames(db, tableName);+ if (existing.size === 0) return;+ for (const [name, type] of columns) {+ if (!existing.has(name)) db.exec(`ALTER TABLE \`${tableName}\` ADD \`${name}\` ${type}`);+ }+}++function run(db: Database.Database): void {+ addMissingColumns(db, 'orca_workers', [+ ['execution_device_id', 'text'],+ ['remote_session_id', 'text'],+ ['last_bridged_message_id', 'text'],+ ['remote_released_at', 'integer'],+ ]);+ addMissingColumns(db, 'sessions', [['orca_remote_lead', 'text']]);+}++module.exports = { run };diff --git a/apps/desktop/src/main/device-link/dispatch.ts b/apps/desktop/src/main/device-link/dispatch.tsindex d09203735b..2fede2e5cb 100644--- a/apps/desktop/src/main/device-link/dispatch.ts+++ b/apps/desktop/src/main/device-link/dispatch.ts@@ -89,7 +89,7 @@ import { isModelVisible } from '@cindy/model-providers/sections';import { app } from 'electron';import { remoteDesktop, requestRemoteDesktop } from '../remote-desktop';import { remoteCredentialHost } from '../remote-desktop/credentialHost';-import { REMOTE_DESKTOP_CHANNEL } from '@cindy/device-link';+import { ORCA_REMOTE_WORKER_OPEN_CHANNEL, REMOTE_DESKTOP_CHANNEL } from '@cindy/device-link';import type { DeviceLinkClient } from '@cindy/device-link';import { isDeferredHistoryPush, deferredToolBoundary } from './historyViewPush';import { mapHistoryViewMessages, type HistoryMessageSource, type HistoryViewItem } from '@cindy/maker-shared/message-window';@@ -302,6 +302,8 @@ export type { ActiveController } from './subscriptions';*/const PATH_GUARDED_CHANNELS: ReadonlyMap<string, 'workingDir' | 'baseRepo'> = new Map([['maker:create-session', 'workingDir'],+ // 协同远端 Worker 指定本机目录时同口径收敛;不指定则由本机分配任务目录。+ [ORCA_REMOTE_WORKER_OPEN_CHANNEL, 'workingDir'],['worktree:create', 'baseRepo'],]);diff --git a/apps/desktop/src/main/localDb/__tests__/conversationSearch.test.ts b/apps/desktop/src/main/localDb/__tests__/conversationSearch.test.tsindex c9ed53acc8..ca721b6b10 100644--- a/apps/desktop/src/main/localDb/__tests__/conversationSearch.test.ts+++ b/apps/desktop/src/main/localDb/__tests__/conversationSearch.test.ts@@ -121,6 +121,7 @@ function createSearchDb(): Database.Database {writable_dirs TEXT NOT NULL DEFAULT '[]',remote_host_id TEXT,agent_device_id TEXT,+ orca_remote_lead TEXT,active_turn_started_at INTEGER,active_turn_pid INTEGER,last_turn_ended_at INTEGER,diff --git a/apps/desktop/src/main/localDb/__tests__/drizzle-split.spike.test.ts b/apps/desktop/src/main/localDb/__tests__/drizzle-split.spike.test.tsindex 11b61500ec..9e73b1d17a 100644--- a/apps/desktop/src/main/localDb/__tests__/drizzle-split.spike.test.ts+++ b/apps/desktop/src/main/localDb/__tests__/drizzle-split.spike.test.ts@@ -123,6 +123,14 @@ async function runMigrationStatement(target: DbClient, statement: string): Promi}function applyMigrationScriptSync(db: Sqlite, fileName: string): void {+ if (fileName === '0124_funny_glorian.sql') {+ ensureColumnSync(db, 'orca_workers', 'execution_device_id', 'text');+ ensureColumnSync(db, 'orca_workers', 'remote_session_id', 'text');+ ensureColumnSync(db, 'orca_workers', 'last_bridged_message_id', 'text');+ ensureColumnSync(db, 'orca_workers', 'remote_released_at', 'integer');+ ensureColumnSync(db, 'sessions', 'orca_remote_lead', 'text');+ return;+ }if (fileName === '0097_fresh_stryfe.sql') {ensureColumnSync(db, 'sessions', 'list_preview', 'text');ensureColumnSync(db, 'sessions', 'list_preview_role', 'text');@@ -219,6 +227,14 @@ function applyMigrationScriptSync(db: Sqlite, fileName: string): void {}async function applyMigrationScript(target: DbClient, fileName: string): Promise<void> {+ if (fileName === '0124_funny_glorian.sql') {+ await ensureColumn(target, 'orca_workers', 'execution_device_id', 'text');+ await ensureColumn(target, 'orca_workers', 'remote_session_id', 'text');+ await ensureColumn(target, 'orca_workers', 'last_bridged_message_id', 'text');+ await ensureColumn(target, 'orca_workers', 'remote_released_at', 'integer');+ await ensureColumn(target, 'sessions', 'orca_remote_lead', 'text');+ return;+ }if (fileName === '0097_fresh_stryfe.sql') {await ensureColumn(target, 'sessions', 'list_preview', 'text');await ensureColumn(target, 'sessions', 'list_preview_role', 'text');diff --git a/apps/desktop/src/main/localDb/__tests__/orcaTeamStore.test.ts b/apps/desktop/src/main/localDb/__tests__/orcaTeamStore.test.tsindex 6dbb19158c..bf4beac22d 100644--- a/apps/desktop/src/main/localDb/__tests__/orcaTeamStore.test.ts+++ b/apps/desktop/src/main/localDb/__tests__/orcaTeamStore.test.ts@@ -434,6 +434,7 @@ describe('orcaTeamStore', () => {writable_dirs TEXT NOT NULL DEFAULT '[]',remote_host_id TEXT,agent_device_id TEXT,+ orca_remote_lead TEXT,provider_id TEXT,active_turn_started_at INTEGER,active_turn_pid INTEGER,@@ -471,6 +472,10 @@ describe('orcaTeamStore', () => {role TEXT NOT NULL DEFAULT 'developer',focused INTEGER NOT NULL DEFAULT 0,idle_since INTEGER,+ execution_device_id TEXT,+ remote_session_id TEXT,+ last_bridged_message_id TEXT,+ remote_released_at INTEGER,created_at INTEGER NOT NULL,updated_at INTEGER NOT NULL);diff --git a/apps/desktop/src/main/localDb/client/__tests__/drizzleProxy.test.ts b/apps/desktop/src/main/localDb/client/__tests__/drizzleProxy.test.tsindex 563b09d6a8..7d5f74e15d 100644--- a/apps/desktop/src/main/localDb/client/__tests__/drizzleProxy.test.ts+++ b/apps/desktop/src/main/localDb/client/__tests__/drizzleProxy.test.ts@@ -55,6 +55,7 @@ const DRIZZLE_PROXY_SCHEMA = [writable_dirs TEXT NOT NULL DEFAULT '[]',remote_host_id TEXT,agent_device_id TEXT,+ orca_remote_lead TEXT,active_turn_started_at INTEGER,active_turn_pid INTEGER,last_turn_ended_at INTEGER,diff --git a/apps/desktop/src/main/localDb/client/__tests__/tx.test.ts b/apps/desktop/src/main/localDb/client/__tests__/tx.test.tsindex 6fc68b530d..685c908f09 100644--- a/apps/desktop/src/main/localDb/client/__tests__/tx.test.ts+++ b/apps/desktop/src/main/localDb/client/__tests__/tx.test.ts@@ -137,6 +137,10 @@ CREATE TABLE orca_workers (role TEXT NOT NULL DEFAULT 'developer',focused INTEGER NOT NULL DEFAULT 0,idle_since INTEGER,+ execution_device_id TEXT,+ remote_session_id TEXT,+ last_bridged_message_id TEXT,+ remote_released_at INTEGER,created_at INTEGER NOT NULL,updated_at INTEGER NOT NULL);diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.tsindex 7f5e499c48..12a52d124b 100644--- a/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts+++ b/apps/desktop/src/main/localDb/ipc/__tests__/botCanonicalSession.test.ts@@ -293,6 +293,7 @@ function createDb(filename = ':memory:'): void {writable_dirs TEXT NOT NULL DEFAULT '[]',remote_host_id TEXT,agent_device_id TEXT,+ orca_remote_lead TEXT,source TEXT NOT NULL DEFAULT 'desktop',created_at INTEGER NOT NULL,updated_at INTEGER NOT NULL,diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/sessionAutoTitlePersist.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/sessionAutoTitlePersist.test.tsindex d80715cd7d..b56e428d16 100644--- a/apps/desktop/src/main/localDb/ipc/__tests__/sessionAutoTitlePersist.test.ts+++ b/apps/desktop/src/main/localDb/ipc/__tests__/sessionAutoTitlePersist.test.ts@@ -107,6 +107,7 @@ function createDb(initialTitle: string): void {orca_role TEXT,remote_host_id TEXT,agent_device_id TEXT,+ orca_remote_lead TEXT,codex_history_has_product_prompt INTEGER,codex_plan_json TEXT,im_bot_context_id TEXT,diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsRestoreIfArchived.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsRestoreIfArchived.test.tsindex 8b11f92d9d..a5cf959ea5 100644--- a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsRestoreIfArchived.test.ts+++ b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsRestoreIfArchived.test.ts@@ -124,6 +124,7 @@ function createDb(): void {orca_role TEXT,remote_host_id TEXT,agent_device_id TEXT,+ orca_remote_lead TEXT,codex_history_has_product_prompt INTEGER,codex_plan_json TEXT,im_bot_context_id TEXT,diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.tsindex ae05185701..d15b1bc1e2 100644--- a/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts+++ b/apps/desktop/src/main/localDb/ipc/__tests__/sessionsUpdate.test.ts@@ -239,6 +239,7 @@ function createDb(): void {orca_role TEXT,remote_host_id TEXT,agent_device_id TEXT,+ orca_remote_lead TEXT,codex_history_has_product_prompt INTEGER,codex_plan_json TEXT,im_bot_context_id TEXT,diff --git a/apps/desktop/src/main/localDb/ipc/sessions.ts b/apps/desktop/src/main/localDb/ipc/sessions.tsindex cb7453c15c..8470730d1b 100644--- a/apps/desktop/src/main/localDb/ipc/sessions.ts+++ b/apps/desktop/src/main/localDb/ipc/sessions.ts@@ -833,6 +833,8 @@ export interface SessionRowSnapshot {agentDeviceId?: string | null;/** Hook exact-takeover must reject internal Orca worker sessions. */orcaRole?: 'lead' | 'worker' | null;+ /** 协同远端 Worker 标记(raw JSON);非空时不能再开启协同。 */+ orcaRemoteLead?: string | null;/** Collab policy gate: remote session 的 codex / claude-code 均放行。 */agentKind?: string | null;/** 会话来源(`bot` = 伙伴会话);限额自动继续据此排除伙伴。 */@@ -861,6 +863,7 @@ async function selectSessionRowSnapshot(id: string): Promise<SessionRowSnapshotremoteHostId: sessions.remoteHostId,agentDeviceId: sessions.agentDeviceId,orcaRole: sessions.orcaRole,+ orcaRemoteLead: sessions.orcaRemoteLead,agentKind: sessions.agentKind,source: sessions.source,model: sessions.model,diff --git a/apps/desktop/src/main/localDb/mapper.ts b/apps/desktop/src/main/localDb/mapper.tsindex 09b1763d3a..659b298334 100644--- a/apps/desktop/src/main/localDb/mapper.ts+++ b/apps/desktop/src/main/localDb/mapper.ts@@ -13,6 +13,11 @@ import { DESKTOP_VISIBLE_SESSION_SOURCES } from '../../shared/sessionSource.js';import { getSessionInterruptionBootAt } from './sessionInterruptionBoot';import { stripInternalWebCitations } from '@cindy/maker-shared/internal-citation';import { markdownPreviewText } from '../../shared/markdownPreviewText.js';+import {+ parseOrcaRemoteLead,+ serializeOrcaRemoteLead,+ type OrcaRemoteLead,+} from '../../shared/orcaRemoteWorker.js';import type {sessions,@@ -268,6 +273,7 @@ export function sessionToCamel(row: SessionRowWithCount): Session {writableDirs: safeParseStringArray(row.writableDirs),remoteHostId: row.remoteHostId ?? null,agentDeviceId: row.agentDeviceId ?? null,+ orcaRemoteLead: parseOrcaRemoteLead(row.orcaRemoteLead ?? null),// interrupted-turn-resume:「疑似中断」判定的两个时间戳(unix ms 原样透出,// renderer 打开会话时比较 startedAt > endedAt,见 sessionActiveTurn.ts)。activeTurnStartedAt: row.activeTurnStartedAt ?? null,@@ -375,6 +381,8 @@ export function sessionCreateToRow(remoteHostId?: string | null;/** Agent 在同账号另一台电脑上运行时那台电脑的 deviceId; null/undefined = Agent 在本机。 */agentDeviceId?: string | null;+ /** 仅运行设备上的协同远端 Worker 入口写入(见 shared/orcaRemoteWorker.ts)。 */+ orcaRemoteLead?: OrcaRemoteLead | null;/*** per-session 来源(供应商)显式选择,落盘 sessions.provider_id(与 update 同列)。* null/undefined = 不显式选,跟随该 agent 的原生默认路由(no-break)。草稿态首次@@ -421,6 +429,7 @@ export function sessionCreateToRow(remoteHostId: normalizeRemoteHostId(body?.remoteHostId),// Agent 运行在另一台电脑时与 SSH 远端互斥:两者同时给出时以 SSH 远端为准、不记录设备。agentDeviceId: normalizeRemoteHostId(body?.remoteHostId) ? null : normalizeRemoteHostId(body?.agentDeviceId),+ orcaRemoteLead: body?.orcaRemoteLead ? serializeOrcaRemoteLead(body.orcaRemoteLead) : null,// 显式来源:trim 后非空才入库,其余(undefined / null / 空串 / 纯空白)一律落 null,// 与 session-provider-store 的 null 语义对齐(null → 回落默认路由,字节级不变)。providerId:diff --git a/apps/desktop/src/main/localDb/schema.ts b/apps/desktop/src/main/localDb/schema.tsindex 730c883e78..a5f655f64b 100644--- a/apps/desktop/src/main/localDb/schema.ts+++ b/apps/desktop/src/main/localDb/schema.ts@@ -235,6 +235,11 @@ export const sessions = sqliteTable(* NULL = Agent 在本机(或 SSH 远端,见 remote_host_id)。与 remote_host_id 互斥。*/agentDeviceId: text('agent_device_id'),+ /**+ * 本任务是另一台电脑上协同 Lead 派来的 Worker(JSON,见 shared/orcaRemoteWorker.ts)。+ * 任务、目录与命令都在本机;Lead 与团队在那台。NULL = 普通任务。+ */+ orcaRemoteLead: text('orca_remote_lead'),/*** interrupted-turn-resume: 最近一次 turn 的启动时刻(unix ms)。与* lastTurnEndedAt 配对做「疑似中断」纯读判定(startedAt > endedAt),两个@@ -742,6 +747,16 @@ export const orcaWorkers = sqliteTable(focused: integer('focused', { mode: 'boolean' }).notNull().default(false),/** multi-worker Phase 1: idle 释放时间戳, NULL = 非 idle */idleSince: integer('idle_since'),+ /**+ * Worker 在同账号另一台电脑运行时那台的设备 id;NULL = 本机 Worker。+ * 此时 session_id 指向本机代理任务行,remote_session_id 是那台上的真实任务。+ */+ executionDeviceId: text('execution_device_id'),+ remoteSessionId: text('remote_session_id'),+ /** 已作为回报送给 Lead 的远端最后一条 assistant 消息 id,用于重连补报去重。 */+ lastBridgedMessageId: text('last_bridged_message_id'),+ /** 已通知运行设备结束协同的时刻;NULL 且已归档 = 待重连后补发。 */+ remoteReleasedAt: integer('remote_released_at'),createdAt: integer('created_at').notNull(),updatedAt: integer('updated_at').notNull(),},diff --git a/apps/desktop/src/main/localDb/worker/__tests__/sessionImportShareTx.test.ts b/apps/desktop/src/main/localDb/worker/__tests__/sessionImportShareTx.test.tsindex e08c6fbdfa..567d68a89d 100644--- a/apps/desktop/src/main/localDb/worker/__tests__/sessionImportShareTx.test.ts+++ b/apps/desktop/src/main/localDb/worker/__tests__/sessionImportShareTx.test.ts@@ -70,6 +70,10 @@ function createTables(db: Database.Database): void {role TEXT NOT NULL DEFAULT 'developer',focused INTEGER NOT NULL DEFAULT 0,idle_since INTEGER,+ execution_device_id TEXT,+ remote_session_id TEXT,+ last_bridged_message_id TEXT,+ remote_released_at INTEGER,created_at INTEGER NOT NULL,updated_at INTEGER NOT NULL);diff --git a/apps/desktop/src/main/maker-ipc/__tests__/orcaRemoteWorkerHost.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/orcaRemoteWorkerHost.test.tsnew file mode 100644index 0000000000..10f465f6a8--- /dev/null+++ b/apps/desktop/src/main/maker-ipc/__tests__/orcaRemoteWorkerHost.test.ts@@ -0,0 +1,181 @@+import { describe, expect, it, vi } from 'vitest';+import {+ ORCA_REMOTE_WORKER_CAPS_CHANNEL,+ ORCA_REMOTE_WORKER_OPEN_CHANNEL,+ ORCA_REMOTE_WORKER_RELEASE_CHANNEL,+ ORCA_REMOTE_WORKER_VERSION,+} from '@cindy/device-link';++import {+ createOrcaRemoteWorkerHost,+ registerOrcaRemoteWorkerHandlers,+ type OrcaRemoteWorkerCaller,+ type OrcaRemoteWorkerExistingSession,+ type OrcaRemoteWorkerHostDeps,+} from '../orcaRemoteWorkerHost.js';+import type { OrcaRemoteLead } from '../../../shared/orcaRemoteWorker.js';++const request = {+ sessionId: 'w_remote_1',+ agentKind: 'claude-code',+ permissionMode: 'auto',+ title: 'Worker · 转写',+ lead: { leadSessionId: 'lead-1', leadTitle: '整理产品访谈报告', workerLabel: '转写' },+};++function setup(+ options: {+ caller?: OrcaRemoteWorkerCaller | null;+ existing?: OrcaRemoteWorkerExistingSession | null;+ } = {},+) {+ const sessions = new Map<string, OrcaRemoteWorkerExistingSession>();+ if (options.existing) sessions.set(request.sessionId, options.existing);+ const deps: OrcaRemoteWorkerHostDeps = {+ getCaller: () =>+ options.caller === undefined+ ? { controllerDeviceId: 'dev-xdpc', controllerName: 'XD-PC' }+ : options.caller,+ readSession: vi.fn(async (id: string) => sessions.get(id) ?? null),+ openSession: vi.fn(async (req, lead: OrcaRemoteLead) => {+ sessions.set(req.sessionId, {+ orcaRemoteLead: lead,+ workingDir: req.workingDir ?? '/Users/demo/Cindy/dialogues/w_remote_1',+ model: 'claude-opus-5-5',+ agentKind: req.agentKind,+ });+ return {+ workingDir: req.workingDir ?? '/Users/demo/Cindy/dialogues/w_remote_1',+ model: 'claude-opus-5-5',+ agentKind: req.agentKind,+ };+ }),+ writeRemoteLead: vi.fn(async (id: string, lead: OrcaRemoteLead) => {+ const current = sessions.get(id);+ if (current) sessions.set(id, { ...current, orcaRemoteLead: lead });+ }),+ withSessionLock: vi.fn(async (_id, task) => task()),+ now: () => 1_000,+ };+ return { deps, sessions, host: createOrcaRemoteWorkerHost(deps) };+}++describe('orca remote worker host', () => {+ it('only answers device-link callers', async () => {+ const { host } = setup({ caller: null });+ expect(() => host.caps()).toThrow(/PRECONDITION_FAILED/);+ await expect(host.open(request)).rejects.toThrow(/PRECONDITION_FAILED/);+ await expect(host.release({ sessionId: 'w_remote_1' })).rejects.toThrow(/PRECONDITION_FAILED/);+ });++ it('refuses shared-task guests', async () => {+ const { host } = setup({ caller: { controllerDeviceId: 'guest', sharedTask: {} } });+ await expect(host.open(request)).rejects.toThrow(/PERMISSION_DENIED/);+ });++ it('reports its protocol version', () => {+ expect(setup().host.caps()).toEqual({ version: ORCA_REMOTE_WORKER_VERSION });+ });++ it('opens a worker task stamped with the server-verified caller, ignoring payload claims', async () => {+ const { host, deps } = setup();+ const result = await host.open({+ ...request,+ leadDeviceId: 'spoofed',+ leadDeviceName: 'spoofed',+ });+ expect(result).toEqual({+ sessionId: 'w_remote_1',+ workingDir: '/Users/demo/Cindy/dialogues/w_remote_1',+ model: 'claude-opus-5-5',+ agentKind: 'claude-code',+ });+ expect(deps.openSession).toHaveBeenCalledWith(+ expect.objectContaining({ sessionId: 'w_remote_1', permissionMode: 'auto' }),+ {+ leadDeviceId: 'dev-xdpc',+ leadDeviceName: 'XD-PC',+ leadSessionId: 'lead-1',+ leadTitle: '整理产品访谈报告',+ workerLabel: '转写',+ },+ );+ expect(deps.withSessionLock).toHaveBeenCalledWith('w_remote_1', expect.any(Function));+ });++ it('is idempotent for the same caller and lead', async () => {+ const { host, deps } = setup();+ const first = await host.open(request);+ const second = await host.open(request);+ expect(second).toEqual(first);+ expect(deps.openSession).toHaveBeenCalledTimes(1);+ });++ it('refuses an id already used by another task or device', async () => {+ const plain = setup({+ existing: { orcaRemoteLead: null, workingDir: '/x', model: 'm', agentKind: 'codex' },+ });+ await expect(plain.host.open(request)).rejects.toThrow(/ALREADY_EXISTS/);++ const other = setup();+ await other.host.open(request);+ const foreign = createOrcaRemoteWorkerHost({+ ...other.deps,+ getCaller: () => ({ controllerDeviceId: 'dev-other' }),+ });+ await expect(foreign.open(request)).rejects.toThrow(/ALREADY_EXISTS/);+ });++ it('does not reopen a released worker under the same id', async () => {+ const { host } = setup();+ await host.open(request);+ await host.release({ sessionId: 'w_remote_1' });+ await expect(host.open(request)).rejects.toThrow(/ALREADY_EXISTS/);+ });++ it('marks release once and keeps the task', async () => {+ const { host, deps, sessions } = setup();+ await host.open(request);+ await expect(host.release({ sessionId: 'w_remote_1' })).resolves.toEqual({ released: true });+ await expect(host.release({ sessionId: 'w_remote_1' })).resolves.toEqual({ released: true });+ expect(deps.writeRemoteLead).toHaveBeenCalledTimes(1);+ expect(sessions.get('w_remote_1')?.orcaRemoteLead?.releasedAt).toBe(1_000);+ });++ it('treats a task deleted on this computer as released', async () => {+ await expect(setup().host.release({ sessionId: 'w_remote_1' })).resolves.toEqual({+ released: true,+ });+ });++ it('refuses to release a task owned by another device', async () => {+ const { host, deps } = setup();+ await host.open(request);+ const foreign = createOrcaRemoteWorkerHost({+ ...deps,+ getCaller: () => ({ controllerDeviceId: 'dev-other' }),+ });+ await expect(foreign.release({ sessionId: 'w_remote_1' })).rejects.toThrow(/NOT_FOUND/);+ });++ it('registers the three device-link channels', async () => {+ const handlers = new Map<string, (event: unknown, ...args: unknown[]) => unknown>();+ const { host } = setup();+ registerOrcaRemoteWorkerHandlers(+ { handle: (channel, handler) => handlers.set(channel, handler) },+ host,+ );+ expect([...handlers.keys()].sort()).toEqual(+ [+ ORCA_REMOTE_WORKER_CAPS_CHANNEL,+ ORCA_REMOTE_WORKER_OPEN_CHANNEL,+ ORCA_REMOTE_WORKER_RELEASE_CHANNEL,+ ].sort(),+ );+ await expect(+ handlers.get(ORCA_REMOTE_WORKER_OPEN_CHANNEL)!({}, request),+ ).resolves.toMatchObject({+ sessionId: 'w_remote_1',+ });+ });+});diff --git a/apps/desktop/src/main/maker-ipc/orcaRemoteWorkerHost.ts b/apps/desktop/src/main/maker-ipc/orcaRemoteWorkerHost.tsnew file mode 100644index 0000000000..b9a7204c2e--- /dev/null+++ b/apps/desktop/src/main/maker-ipc/orcaRemoteWorkerHost.ts@@ -0,0 +1,143 @@+/**+ * 运行设备侧:承接另一台电脑上协同 Lead 派来的 Worker 任务。+ *+ * 只接受 device-link 同账号调用(来源电脑取 server 盖章的 src)。新建的是一条普通任务,+ * 带 sessions.orca_remote_lead 标记:侧栏照常显示并标注来源,不能再开启协同(见+ * register.ts assertLeadCollabProjectEnabled)、不能复制到其他电脑。派活、停止与回报复用+ * 现有会话通道,本模块不涉及。+ */+import {+ ORCA_REMOTE_WORKER_CAPS_CHANNEL,+ ORCA_REMOTE_WORKER_OPEN_CHANNEL,+ ORCA_REMOTE_WORKER_RELEASE_CHANNEL,+ ORCA_REMOTE_WORKER_VERSION,+ parseOrcaRemoteWorkerOpenRequest,+ parseOrcaRemoteWorkerReleaseRequest,+ type OrcaRemoteWorkerCaps,+ type OrcaRemoteWorkerOpenRequest,+ type OrcaRemoteWorkerOpenResult,+} from '@cindy/device-link';++import type { OrcaRemoteLead } from '../../shared/orcaRemoteWorker.js';+import type { IpcHandlerRegistry } from './ipcHandlerRegistry.js';++export interface OrcaRemoteWorkerCaller {+ controllerDeviceId: string;+ controllerName?: string;+ /** 共享任务访客不得使用;dispatch 已按清单拒绝,这里再兜一层。 */+ sharedTask?: unknown;+}++export interface OrcaRemoteWorkerExistingSession {+ orcaRemoteLead: OrcaRemoteLead | null;+ workingDir: string | null;+ model: string;+ agentKind: OrcaRemoteWorkerOpenResult['agentKind'];+}++export interface OrcaRemoteWorkerHostDeps {+ getCaller(): OrcaRemoteWorkerCaller | null;+ readSession(sessionId: string): Promise<OrcaRemoteWorkerExistingSession | null>;+ /**+ * 新建任务并启动 Agent(复用普通开任务事务与模型准入),随后写入远端 Worker 标记并广播。+ * 未给 workingDir 时由本机按自身设置分配任务目录。+ */+ openSession(+ request: OrcaRemoteWorkerOpenRequest,+ lead: OrcaRemoteLead,+ ): Promise<{+ workingDir: string;+ model: string;+ agentKind: OrcaRemoteWorkerOpenResult['agentKind'];+ }>;+ writeRemoteLead(sessionId: string, lead: OrcaRemoteLead): Promise<void>;+ /** 同一任务 id 的 open / release 串行。 */+ withSessionLock<T>(sessionId: string, task: () => Promise<T>): Promise<T>;+ now(): number;+}++function fail(code: string, message: string): never {+ throw new Error(`[${code}] ${message}`);+}++function requireCaller(deps: OrcaRemoteWorkerHostDeps): OrcaRemoteWorkerCaller {+ const caller = deps.getCaller();+ if (!caller || !caller.controllerDeviceId) {+ fail('PRECONDITION_FAILED', 'remote worker requests must come from another device');+ }+ if (caller.sharedTask) fail('PERMISSION_DENIED', 'shared task guests cannot open remote workers');+ return caller;+}++export function createOrcaRemoteWorkerHost(deps: OrcaRemoteWorkerHostDeps) {+ return {+ caps(): OrcaRemoteWorkerCaps {+ requireCaller(deps);+ return { version: ORCA_REMOTE_WORKER_VERSION };+ },++ async open(raw: unknown): Promise<OrcaRemoteWorkerOpenResult> {+ const caller = requireCaller(deps);+ const request = parseOrcaRemoteWorkerOpenRequest(raw);+ return deps.withSessionLock(request.sessionId, async () => {+ const existing = await deps.readSession(request.sessionId);+ if (existing) {+ const lead = existing.orcaRemoteLead;+ // 幂等:同一来源电脑、同一 Lead 重复 open(例如超时后重试)返回同一任务。+ if (+ lead &&+ lead.leadDeviceId === caller.controllerDeviceId &&+ lead.leadSessionId === request.lead.leadSessionId &&+ lead.releasedAt === undefined+ ) {+ return {+ sessionId: request.sessionId,+ workingDir: existing.workingDir ?? '',+ model: existing.model,+ agentKind: existing.agentKind,+ };+ }+ fail('ALREADY_EXISTS', 'a different task already uses this id');+ }+ const lead: OrcaRemoteLead = {+ leadDeviceId: caller.controllerDeviceId,+ leadDeviceName: caller.controllerName ?? '',+ leadSessionId: request.lead.leadSessionId,+ leadTitle: request.lead.leadTitle,+ workerLabel: request.lead.workerLabel,+ };+ const opened = await deps.openSession(request, lead);+ return { sessionId: request.sessionId, ...opened };+ });+ },++ async release(raw: unknown): Promise<{ released: boolean }> {+ const caller = requireCaller(deps);+ const { sessionId } = parseOrcaRemoteWorkerReleaseRequest(raw);+ return deps.withSessionLock(sessionId, async () => {+ const existing = await deps.readSession(sessionId);+ // 任务已被本机用户删除:视为已结束,派活电脑不必再重试。+ if (!existing) return { released: true };+ const lead = existing.orcaRemoteLead;+ if (!lead || lead.leadDeviceId !== caller.controllerDeviceId) {+ fail('NOT_FOUND', 'no remote worker from this device');+ }+ if (lead.releasedAt === undefined) {+ await deps.writeRemoteLead(sessionId, { ...lead, releasedAt: deps.now() });+ }+ return { released: true };+ });+ },+ };+}++export type OrcaRemoteWorkerHost = ReturnType<typeof createOrcaRemoteWorkerHost>;++export function registerOrcaRemoteWorkerHandlers(+ registry: IpcHandlerRegistry,+ host: OrcaRemoteWorkerHost,+): void {+ registry.handle(ORCA_REMOTE_WORKER_CAPS_CHANNEL, () => host.caps());+ registry.handle(ORCA_REMOTE_WORKER_OPEN_CHANNEL, (_event, raw) => host.open(raw));+ registry.handle(ORCA_REMOTE_WORKER_RELEASE_CHANNEL, (_event, raw) => host.release(raw));+}diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.tsindex 79f07c20cf..994cd39b54 100644--- a/apps/desktop/src/main/maker-ipc/register.ts+++ b/apps/desktop/src/main/maker-ipc/register.ts@@ -872,6 +872,15 @@ import {} from './orcaManualInterrupt.js';import { tryInjectProjectContext } from './projectContextInject.js';import { registerMakerSessionCreateHandler } from './sessionCreateHandler.js';+import {+ createOrcaRemoteWorkerHost,+ registerOrcaRemoteWorkerHandlers,+} from './orcaRemoteWorkerHost.js';+import {+ parseOrcaRemoteLead,+ serializeOrcaRemoteLead,+ type OrcaRemoteLead,+} from '../../shared/orcaRemoteWorker.js';import {applyPendingAgentSwitchIfIdle,createPendingAgentSwitchRegistry,@@ -8290,6 +8299,92 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)warnStderr: (agentKind, line) => log.warn(`[${agentKind}/stderr] ${line}`),});+ // 本机作为运行设备:承接另一台电脑上协同 Lead 派来的 Worker 任务(见 orcaRemoteWorkerHost.ts)。+ const writeOrcaRemoteLead = async (sessionId: string, lead: OrcaRemoteLead) => {+ await getDbClient()+ .drizzle.update(sessions)+ .set({ orcaRemoteLead: serializeOrcaRemoteLead(lead) })+ .where(eq(sessions.id, sessionId));+ broadcastSessionPatched(sessionId, { orcaRemoteLead: lead });+ };+ registerOrcaRemoteWorkerHandlers(makerSessionRegistry, createOrcaRemoteWorkerHost({+ getCaller: () => {+ const context = getDeviceLinkInvokeContext();+ return context+ ? {+ controllerDeviceId: context.controllerDeviceId,+ controllerName: context.controllerName,+ sharedTask: context.sharedTask,+ }+ : null;+ },+ readSession: async (sessionId) => {+ const [row] = await getDbClient()+ .drizzle.select({+ orcaRemoteLead: sessions.orcaRemoteLead,+ workingDir: sessions.workingDir,+ model: sessions.model,+ agentKind: sessions.agentKind,+ })+ .from(sessions)+ .where(eq(sessions.id, sessionId))+ .limit(1);+ if (!row) return null;+ return {+ orcaRemoteLead: parseOrcaRemoteLead(row.orcaRemoteLead),+ workingDir: row.workingDir,+ model: row.model,+ agentKind: row.agentKind === 'cc' ? 'claude-code' : (row.agentKind as 'codex' | 'pi'),+ };+ },+ openSession: async (request, lead) => {+ const workspaceKind = request.workingDir ? 'project' : 'dialogue';+ const { row } = await openSession({+ id: request.sessionId,+ body: {+ title: request.title,+ agentKind: request.agentKind === 'claude-code' ? 'cc' : request.agentKind,+ model: request.model,+ providerId: request.providerId,+ effort: request.effort,+ fastMode: request.fastMode,+ permissionMode: request.permissionMode,+ workspaceKind,+ workingDir: request.workingDir,+ orcaRemoteLead: lead,+ },+ }, async (opened, assertCurrent) => {+ const agentKind = opened.agentKind === 'codex' || opened.agentKind === 'pi'+ ? opened.agentKind+ : 'claude-code';+ await bootstrapSession(buildCreateOptsWithStderr({+ id: opened.id,+ agentKind,+ workspaceKind: opened.workspaceKind,+ // openSession 已为 dialogue 分配目录;project 由调用方给出并经 device-link 目录守卫。+ workingDir: opened.workingDir ?? '',+ model: opened.model,+ providerId: opened.providerId,+ effort: (opened.effort || undefined) as CreateOpts['effort'],+ fastMode: opened.fastMode,+ permissionMode: opened.permissionMode as CreateOpts['permissionMode'],+ title: opened.title,+ }), assertCurrent);+ // maker.createSession 只写通用列;来源标记在广播 created 之前补上。+ await getDbClient()+ .drizzle.update(sessions)+ .set({ orcaRemoteLead: serializeOrcaRemoteLead(lead) })+ .where(eq(sessions.id, opened.id));+ });+ broadcastSessionCreated(row.id);+ const agentKind = row.agentKind === 'cc' ? 'claude-code' : (row.agentKind as 'codex' | 'pi');+ return { workingDir: row.workingDir ?? '', model: row.model, agentKind };+ },+ writeRemoteLead: writeOrcaRemoteLead,+ withSessionLock: withSendToSessionLock,+ now: Date.now,+ }));+const readSourceReviewCards = async (sourceSessionId: string) =>getDbClient().drizzle.select({@@ -9363,6 +9458,11 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)await assertReviewSettingsUnlocked(leadSessionId);const lead = maker.getSession(leadSessionId);const leadRow = await getSessionRowSnapshot(leadSessionId);+ // Worker 不能再当 Lead:本机 Worker 的 MCP 工具已按 vendorOptions 拒绝,这里补上+ // IPC / 远程入口;另一台电脑派来的远端 Worker 同样不能嵌套开启协同。+ if (leadRow?.orcaRole === 'worker' || leadRow?.orcaRemoteLead) {+ throwIpcError('PRECONDITION_FAILED', '[WORKER_CANNOT_NEST] a worker task cannot start collaboration');+ }const rawWorkingDir =typeof leadRow?.workingDir === 'string' ? leadRow.workingDir : lead?.workDir;const normalizedWorkingDir =diff --git a/apps/desktop/src/main/task-migration/__tests__/service.test.ts b/apps/desktop/src/main/task-migration/__tests__/service.test.tsindex 88f58c9e6a..38fe675272 100644--- a/apps/desktop/src/main/task-migration/__tests__/service.test.ts+++ b/apps/desktop/src/main/task-migration/__tests__/service.test.ts@@ -534,6 +534,16 @@ describe('resumable cross-computer copy', () => {expect(state.snapshot).not.toHaveBeenCalled();});+ it('rejects a worker task opened here by another computer’s collaboration lead', async () => {+ state.rows.get('A')!.get('fork')!.orcaRemoteLead = JSON.stringify({+ leadDeviceId: 'C',+ leadSessionId: 'lead-on-c',+ workerLabel: '转写',+ });+ await expect(start()).rejects.toThrow('MIGRATION_TASK_UNSUPPORTED');+ expect(state.exported).not.toHaveBeenCalled();+ });+it('rejects an idle runtime whose terminal delivery or accepted queue is still pending', async () => {state.boundaryBusy = true;await expect(start()).rejects.toThrow('MIGRATION_TASK_RUNNING');diff --git a/apps/desktop/src/main/task-migration/service.ts b/apps/desktop/src/main/task-migration/service.tsindex 79c0fc7ad1..e428e63d27 100644--- a/apps/desktop/src/main/task-migration/service.ts+++ b/apps/desktop/src/main/task-migration/service.ts@@ -237,6 +237,7 @@ interface SourceSession {workspaceKind: string;remoteHostId: string | null;agentDeviceId: string | null;+ orcaRemoteLead: string | null;status: string;source: string;orcaRole: string | null;@@ -249,7 +250,7 @@ async function assertSource(worker = false,): Promise<SourceSession> {const row = await scope.db.queryOne<SourceSession>(- 'SELECT id, working_dir AS workingDir, workspace_kind AS workspaceKind, remote_host_id AS remoteHostId, agent_device_id AS agentDeviceId, status, source, orca_role AS orcaRole, agent_kind AS agentKind, updated_at AS updatedAt FROM sessions WHERE id = ?',+ 'SELECT id, working_dir AS workingDir, workspace_kind AS workspaceKind, remote_host_id AS remoteHostId, agent_device_id AS agentDeviceId, orca_remote_lead AS orcaRemoteLead, status, source, orca_role AS orcaRole, agent_kind AS agentKind, updated_at AS updatedAt FROM sessions WHERE id = ?',[sessionId],);scope.assertCurrent();@@ -260,6 +261,8 @@ async function assertSource(row.remoteHostId ||// Agent 在另一台电脑运行的任务:Agent 会话记录在那台,本机无法完整复制。row.agentDeviceId ||+ // 另一台电脑上协同 Lead 派来的 Worker:协同归属在那台,不随任务复制。+ row.orcaRemoteLead ||(worker ? row.orcaRole !== 'worker' : row.orcaRole === 'worker') ||!['desktop', 'shared', 'feishu'].includes(row.source))diff --git a/apps/desktop/src/renderer/__tests__/collabEntryPolicy.test.ts b/apps/desktop/src/renderer/__tests__/collabEntryPolicy.test.tsindex 2d4604e1b3..8b7ea34889 100644--- a/apps/desktop/src/renderer/__tests__/collabEntryPolicy.test.ts+++ b/apps/desktop/src/renderer/__tests__/collabEntryPolicy.test.ts@@ -109,6 +109,16 @@ describe('resolveCollabEntryPolicy 五类场景', () => {).toBe(false);});+ it('另一台电脑派来的远端 Worker:同样不挂入口', () => {+ expect(+ resolveCollabEntryPolicy({+ workspaceKind: 'project',+ workingDir: '/Users/me/Interviews',+ orcaRemoteWorker: true,+ }).eligible,+ ).toBe(false);+ });+it('Orca Lead 会话本身仍 eligible(ON 态的 pill 要能渲染成关闭按钮)', () => {expect(resolveCollabEntryPolicy({diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsxindex ef9e34cd53..2f91389275 100644--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx@@ -2955,6 +2955,7 @@ export function CCAgentSessionView({workspaceKind: collabWorkspaceKind,workingDir: session?.workingDir,orcaRole: session?.orcaRole,+ orcaRemoteWorker: !!session?.orcaRemoteLead,remoteHostId: session?.remoteHostId,// 粘滞归属:relay 瞬时重连清空注册表的窗口内不把远程会话误判成本机 —— 误判会让// 协同策略退回查控制端本机,读到的是另一台机器的开关。diff --git a/apps/desktop/src/renderer/features/cc-agent/OrcaRemoteLeadBadge.tsx b/apps/desktop/src/renderer/features/cc-agent/OrcaRemoteLeadBadge.tsxnew file mode 100644index 0000000000..ec0ed1962d--- /dev/null+++ b/apps/desktop/src/renderer/features/cc-agent/OrcaRemoteLeadBadge.tsx@@ -0,0 +1,39 @@+import { Users } from 'lucide-react';+import { useTranslation } from 'react-i18next';++import type { Session } from '@/lib/ccAgent.types';+import { Tip } from '@/components/ui/tooltip';+import { WINDOW_NO_DRAG_STYLE } from '@/components/layout/windowDrag';++/**+ * 运行设备上的协同远端 Worker:标明是哪台电脑的 Lead 派来的。+ * 本机直接发的消息按插话处理,不回报给那台的 Lead;派活电脑结束协同后显示「协同已结束」。+ */+export function OrcaRemoteLeadBadge({ session }: { session: Session }) {+ const { t } = useTranslation();+ const lead = session.orcaRemoteLead;+ if (!lead) return null;+ const device = lead.leadDeviceName || t('ccAgent.sessionHeader.orcaRemoteLeadUnknownDevice');+ const released = lead.releasedAt !== undefined;+ const label = released+ ? t('ccAgent.sessionHeader.orcaRemoteLeadReleased', { device })+ : t('ccAgent.sessionHeader.orcaRemoteLead', { device });+ return (+ <Tip+ text={t('ccAgent.sessionHeader.orcaRemoteLeadTip', {+ device,+ lead: lead.leadTitle || device,+ })}+ >+ <span+ role="note"+ aria-label={label}+ className="ml-2 inline-flex min-w-0 max-w-56 shrink-0 items-center gap-1 rounded-full bg-[var(--surface-chip)] px-2 py-0.5 text-11 leading-4 text-[var(--text-secondary)]"+ style={WINDOW_NO_DRAG_STYLE}+ >+ <Users size={12} aria-hidden="true" className="shrink-0" />+ <span className="truncate">{label}</span>+ </span>+ </Tip>+ );+}diff --git a/apps/desktop/src/renderer/features/cc-agent/SessionContentHeader.tsx b/apps/desktop/src/renderer/features/cc-agent/SessionContentHeader.tsxindex f983ad5ef9..f505a72eba 100644--- a/apps/desktop/src/renderer/features/cc-agent/SessionContentHeader.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/SessionContentHeader.tsx@@ -64,6 +64,7 @@ import {import { isOrcaLeadSession, resolveSessionRoute } from '@/lib/orcaSessionIdentity';import { revalidateWorkersProjection } from './hooks/workerProjectionStore';import { GitContextBadge } from './GitContextBadge';+import { OrcaRemoteLeadBadge } from './OrcaRemoteLeadBadge';import { SessionRenameInput } from './SessionRenameInput';import { useSessionBoundSchedules } from '@/features/scheduler/lib/scheduleSessionBinding';import { ScheduleBindingBadge } from './sidebar/ScheduleBindingBadge';@@ -652,6 +653,8 @@ export function SessionContentHeader({</span>)}+ {!isEditing && <OrcaRemoteLeadBadge session={session} />}+{!isEditing && !readOnly && (!sharedGuest || session.status === 'active') && (// 菜单打开就把归档/删除的 dirty 预检发出去:用户从展开菜单到点条目至少// 一次反应时间,足够这次 git status 跑完,点下去时命中缓存、零等待。diff --git a/apps/desktop/src/renderer/features/cc-agent/collabEntryPolicy.ts b/apps/desktop/src/renderer/features/cc-agent/collabEntryPolicy.tsindex db57854142..b5d78245e4 100644--- a/apps/desktop/src/renderer/features/cc-agent/collabEntryPolicy.ts+++ b/apps/desktop/src/renderer/features/cc-agent/collabEntryPolicy.ts@@ -22,6 +22,8 @@ export interface CollabEntryTarget {workingDir?: string | null;/** sessions.orca_role。'worker' = Orca Worker 子会话,自己不能再开协同。草稿恒为空。 */orcaRole?: string | null;+ /** 另一台电脑上协同 Lead 派来的 Worker(sessions.orca_remote_lead 非空),同样不能再开协同。 */+ orcaRemoteWorker?: boolean;/** SSH 远端工作区所属 host。非空 = workingDir 是那台远端主机上的路径。 */remoteHostId?: string | null;/** device-link 被控设备 deviceId。非空 = 这个项目和会话的真身都在那台被控设备上。 */@@ -64,12 +66,13 @@ function nonEmpty(value: string | null | undefined): string | null {* | dialogue 草稿(尚无运行目录) | ✅ | skipProjectQuery(仅用户/全局级) |* | 本地 dialogue(已有运行目录) | ✅ | 查询目录;Main 区分托管/显式目录 |* | Orca Worker 子会话 | ❌ | — |+ * | 另一台电脑派来的远端 Worker | ❌ | — |** 两个远端维度**可以同时成立**(在被控设备上打开的 SSH 远端项目):此时既要隧道到被控端,* 又要在被控端跳过项目级 —— 两个字段互相独立,不是二选一。*/export function resolveCollabEntryPolicy(target: CollabEntryTarget): CollabEntryPolicyScope {- if (target.orcaRole === 'worker') return NOT_ELIGIBLE;+ if (target.orcaRole === 'worker' || target.orcaRemoteWorker) return NOT_ELIGIBLE;if (target.workspaceKind !== 'project' && target.workspaceKind !== 'dialogue') {return NOT_ELIGIBLE;}diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/TaskMoveSubmenu.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/TaskMoveSubmenu.tsxindex b01500255f..1f254de1c0 100644--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/TaskMoveSubmenu.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/TaskMoveSubmenu.tsx@@ -189,7 +189,9 @@ export function TaskMoveSubmenu({localProjects)}{['desktop', 'shared', 'feishu'].includes(session.source ?? 'desktop') &&- session.orcaRole !== 'worker' && (+ session.orcaRole !== 'worker' &&+ // 另一台电脑派来的协同 Worker:协同归属在那台,不复制到其他电脑(main 同样拒绝)。+ !session.orcaRemoteLead && (<><DropdownMenuSeparator /><div className="px-3 py-1.5 text-xs text-[var(--cmd-palette-item-meta)]">diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex 352c25bebd..53275d4892 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -11358,7 +11358,11 @@"untitled": "Untitled session","moreActions": "More actions","agentDevice": "Agent runs on {{device}}",- "agentDeviceOffline": "Agent runs on {{device}}, which is offline — it continues once that computer is back"+ "agentDeviceOffline": "Agent runs on {{device}}, which is offline — it continues once that computer is back",+ "orcaRemoteLead": "Collaboration from {{device}}",+ "orcaRemoteLeadReleased": "Collaboration ended · from {{device}}",+ "orcaRemoteLeadUnknownDevice": "another computer",+ "orcaRemoteLeadTip": "A Worker for “{{lead}}” on {{device}}. Its task, folder and commands run on this computer. Messages you send here are not reported to the Lead."},"gitContext": {"detached": "Detached HEAD",diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex b76a65199e..b8d861bb88 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -11330,7 +11330,11 @@"untitled": "無題のセッション","moreActions": "その他の操作","agentDevice": "Agent は {{device}} で実行中",- "agentDeviceOffline": "Agent は {{device}} で実行中ですが、そのパソコンはオフラインです。接続されると続行します"+ "agentDeviceOffline": "Agent は {{device}} で実行中ですが、そのパソコンはオフラインです。接続されると続行します",+ "orcaRemoteLead": "{{device}} からの協同",+ "orcaRemoteLeadReleased": "協同は終了しました · {{device}} から",+ "orcaRemoteLeadUnknownDevice": "別のパソコン",+ "orcaRemoteLeadTip": "{{device}} の「{{lead}}」の Worker です。タスク、フォルダー、コマンドはこのパソコンで実行されます。ここで送ったメッセージは Lead に報告されません。"},"gitContext": {"detached": "Detached HEAD",diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex ae9a846baf..e8c3ece04c 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -11330,7 +11330,11 @@"untitled": "제목 없는 세션","moreActions": "더 보기","agentDevice": "Agent가 {{device}}에서 실행 중",- "agentDeviceOffline": "Agent가 {{device}}에서 실행 중이지만 그 컴퓨터가 오프라인입니다. 다시 연결되면 계속됩니다"+ "agentDeviceOffline": "Agent가 {{device}}에서 실행 중이지만 그 컴퓨터가 오프라인입니다. 다시 연결되면 계속됩니다",+ "orcaRemoteLead": "{{device}}에서 온 협업",+ "orcaRemoteLeadReleased": "협업 종료됨 · {{device}}에서",+ "orcaRemoteLeadUnknownDevice": "다른 컴퓨터",+ "orcaRemoteLeadTip": "{{device}}에 있는 “{{lead}}”의 Worker입니다. 작업, 폴더, 명령은 이 컴퓨터에서 실행됩니다. 여기서 보낸 메시지는 Lead에 보고되지 않습니다."},"gitContext": {"detached": "Detached HEAD",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex a75e0ebb34..42f248fe2e 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -11330,7 +11330,11 @@"untitled": "未命名任务","moreActions": "更多操作","agentDevice": "Agent 在 {{device}} 上运行",- "agentDeviceOffline": "Agent 在 {{device}} 上运行,那台电脑现在离线,连上后才能继续"+ "agentDeviceOffline": "Agent 在 {{device}} 上运行,那台电脑现在离线,连上后才能继续",+ "orcaRemoteLead": "来自 {{device}} 的协同",+ "orcaRemoteLeadReleased": "协同已结束 · 来自 {{device}}",+ "orcaRemoteLeadUnknownDevice": "另一台电脑",+ "orcaRemoteLeadTip": "{{device}} 上「{{lead}}」的 Worker。任务、目录和命令都在这台电脑运行;你在这里发的消息不会回报给 Lead。"},"gitContext": {"detached": "分离 HEAD",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.jsonindex 5982b92213..7a3b3fddc6 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json@@ -11330,7 +11330,11 @@"untitled": "未命名任務","moreActions": "更多操作","agentDevice": "Agent 在 {{device}} 上執行",- "agentDeviceOffline": "Agent 在 {{device}} 上執行,那臺電腦目前離線,連上後才能繼續"+ "agentDeviceOffline": "Agent 在 {{device}} 上執行,那臺電腦目前離線,連上後才能繼續",+ "orcaRemoteLead": "來自 {{device}} 的協同",+ "orcaRemoteLeadReleased": "協同已結束 · 來自 {{device}}",+ "orcaRemoteLeadUnknownDevice": "另一臺電腦",+ "orcaRemoteLeadTip": "{{device}} 上「{{lead}}」的 Worker。任務、目錄和命令都在這臺電腦執行;你在這裡傳送的訊息不會回報給 Lead。"},"gitContext": {"detached": "分離 HEAD",diff --git a/apps/desktop/src/renderer/lib/ccAgent.types.ts b/apps/desktop/src/renderer/lib/ccAgent.types.tsindex 3f295ea8ee..9a64344e2b 100644--- a/apps/desktop/src/renderer/lib/ccAgent.types.ts+++ b/apps/desktop/src/renderer/lib/ccAgent.types.ts@@ -5,6 +5,7 @@ import type { TurnUsageDetails } from '../../shared/turnUsageDetails';import type { RegionalMoney } from '../../shared/regionalMoney';import type { AutoResumeInfo, RecoveryCheckpoint } from '../../shared/agentInputQueue';import type { ReviewRunMeta } from '../../shared/reviewRun';+import type { OrcaRemoteLead } from '../../shared/orcaRemoteWorker';import type { AgentTaskTerminalStatus } from '@cindy/maker-shared/agent-task';import type {MessageSourceDevice,@@ -414,6 +415,11 @@ export interface Session {* 在那台电脑上。null/undefined = Agent 在本机。与 remoteHostId 互斥。*/agentDeviceId?: string | null;+ /**+ * 本任务是另一台电脑上协同 Lead 派来的 Worker(任务、目录与命令都在本机)。+ * null/undefined = 普通任务;旧版本 payload 没有该字段。+ */+ orcaRemoteLead?: OrcaRemoteLead | null;/*** device-link 跨设备远程控制:本 session 实际归属的**被控设备 deviceId**。* 仅存在于控制端**内存**里(由 remoteProjectsStore 注入),**永不落本地 DB**——diff --git a/apps/desktop/src/shared/__tests__/orcaRemoteWorker.test.ts b/apps/desktop/src/shared/__tests__/orcaRemoteWorker.test.tsnew file mode 100644index 0000000000..66d15d704d--- /dev/null+++ b/apps/desktop/src/shared/__tests__/orcaRemoteWorker.test.ts@@ -0,0 +1,46 @@+import { describe, expect, it } from 'vitest';++import { parseOrcaRemoteLead, serializeOrcaRemoteLead } from '../orcaRemoteWorker';++const lead = {+ leadDeviceId: 'dev-xdpc',+ leadDeviceName: 'XD-PC',+ leadSessionId: 'lead-1',+ leadTitle: '整理产品访谈报告',+ workerLabel: '转写',+};++describe('orca remote lead marker', () => {+ it('round-trips through the stored JSON', () => {+ expect(parseOrcaRemoteLead(serializeOrcaRemoteLead(lead))).toEqual(lead);+ expect(parseOrcaRemoteLead(serializeOrcaRemoteLead({ ...lead, releasedAt: 5 }))).toEqual({+ ...lead,+ releasedAt: 5,+ });+ });++ it('treats missing, corrupt or incomplete values as a normal task', () => {+ expect(parseOrcaRemoteLead(null)).toBeNull();+ expect(parseOrcaRemoteLead('{not json')).toBeNull();+ expect(parseOrcaRemoteLead('[]')).toBeNull();+ expect(parseOrcaRemoteLead({ ...lead, leadDeviceId: undefined })).toBeNull();+ expect(parseOrcaRemoteLead({ ...lead, workerLabel: 'x'.repeat(33) })).toBeNull();+ });++ it('fills optional display text and drops invalid release stamps', () => {+ expect(+ parseOrcaRemoteLead({+ leadDeviceId: 'dev-xdpc',+ leadSessionId: 'lead-1',+ workerLabel: '转写',+ releasedAt: 'soon',+ }),+ ).toEqual({+ leadDeviceId: 'dev-xdpc',+ leadDeviceName: '',+ leadSessionId: 'lead-1',+ leadTitle: '',+ workerLabel: '转写',+ });+ });+});diff --git a/apps/desktop/src/shared/orcaRemoteWorker.ts b/apps/desktop/src/shared/orcaRemoteWorker.tsnew file mode 100644index 0000000000..0dd9a24072--- /dev/null+++ b/apps/desktop/src/shared/orcaRemoteWorker.ts@@ -0,0 +1,57 @@+/**+ * 运行设备上的「协同远端 Worker」标记(sessions.orca_remote_lead 的 JSON 形态)。+ *+ * 任务、目录与命令都在本机;派活的 Lead 与团队在另一台电脑。它在侧栏照常显示并标注来源,+ * 不能再开启协同、不能复制到其他电脑。main / renderer 共用,必须保持 renderer-safe。+ */+export interface OrcaRemoteLead {+ /** 派活电脑的设备 id(server 盖章的 src,不采信载荷自报)。 */+ leadDeviceId: string;+ /** 派活电脑的展示名快照,只用于归属展示。 */+ leadDeviceName: string;+ leadSessionId: string;+ leadTitle: string;+ workerLabel: string;+ /** 派活电脑通知结束协同的时刻(unix ms);缺省 = 协同仍在进行。 */+ releasedAt?: number;+}++const MAX_TEXT = 200;++function text(value: unknown, max = MAX_TEXT): string | null {+ return typeof value === 'string' && value.length <= max ? value : null;+}++/** 宽松解析:损坏或缺字段时返回 null(按普通任务处理),不抛错。 */+export function parseOrcaRemoteLead(raw: unknown): OrcaRemoteLead | null {+ let value = raw;+ if (typeof raw === 'string') {+ try {+ value = JSON.parse(raw);+ } catch {+ return null;+ }+ }+ if (!value || typeof value !== 'object' || Array.isArray(value)) return null;+ const record = value as Record<string, unknown>;+ const leadDeviceId = text(record.leadDeviceId, 128);+ const leadSessionId = text(record.leadSessionId, 128);+ const workerLabel = text(record.workerLabel, 32);+ if (!leadDeviceId || !leadSessionId || !workerLabel) return null;+ const releasedAt =+ typeof record.releasedAt === 'number' && Number.isFinite(record.releasedAt)+ ? record.releasedAt+ : undefined;+ return {+ leadDeviceId,+ leadDeviceName: text(record.leadDeviceName) ?? '',+ leadSessionId,+ leadTitle: text(record.leadTitle) ?? '',+ workerLabel,+ ...(releasedAt !== undefined ? { releasedAt } : {}),+ };+}++export function serializeOrcaRemoteLead(lead: OrcaRemoteLead): string {+ return JSON.stringify(lead);+}diff --git a/docs/design-previews/cross-device-delegation/index.html b/docs/design-previews/cross-device-delegation/index.htmlnew file mode 100644index 0000000000..7668780a46--- /dev/null+++ b/docs/design-previews/cross-device-delegation/index.html@@ -0,0 +1,1903 @@+<!doctype html>+<html lang="zh-CN" data-theme="light">+ <head>+ <meta charset="utf-8" />+ <meta name="viewport" content="width=device-width, initial-scale=1" />+ <meta name="color-scheme" content="light dark" />+ <link rel="icon" href="data:," />+ <title>Cindy · 协同 Worker 跨设备运行原型</title>+ <style>+ /* Standalone preview aliases: DESIGN.md §§2–5, 10, 14. No application wiring. */+ :root {+ color-scheme: light;+ --surface: #f8f8f6;+ --surface-elevated: #fff;+ --surface-chip: #e5e5e5;+ --border-default: #d7d7d4;+ --text-primary: #262626;+ --text-secondary: #737373;+ --text-tertiary: #a3a3a3;+ --status-running: #bc570e;+ --status-success: #258147;+ --status-error: #c72c40;+ --focus-ring: #417cdd;+ --overlay: rgb(38 38 38 / 0.22);+ }+ [data-theme="dark"] {+ color-scheme: dark;+ --surface: #1f1f1e;+ --surface-elevated: #2c2c2a;+ --surface-chip: #3c3c3a;+ --border-default: #3c3c3a;+ --text-primary: #d4d4d4;+ --text-secondary: #a3a3a3;+ --text-tertiary: #858581;+ --status-running: #f49a52;+ --status-success: #78c18d;+ --status-error: #f18c97;+ --overlay: rgb(0 0 0 / 0.45);+ }+ * {+ box-sizing: border-box;+ }+ body {+ margin: 0;+ font:+ 14px/1.6 Inter,+ -apple-system,+ BlinkMacSystemFont,+ "Segoe UI",+ "Microsoft YaHei",+ sans-serif;+ color: var(--text-primary);+ background: var(--surface);+ }+ button,+ input,+ textarea,+ select {+ font: inherit;+ color: inherit;+ }+ button,+ select {+ cursor: pointer;+ }+ button {+ display: inline-flex;+ align-items: center;+ justify-content: center;+ gap: 6px;+ min-height: 32px;+ border: 1px solid var(--border-default);+ border-radius: 9999px;+ padding: 4px 13px;+ font-size: 13px;+ font-weight: 500;+ line-height: 22px;+ background: var(--surface-elevated);+ transition: background 150ms;+ }+ button:hover:not(:disabled) {+ background: color-mix(+ in srgb,+ var(--surface-elevated),+ var(--text-primary) 8%+ );+ }+ button:active:not(:disabled) {+ background: color-mix(+ in srgb,+ var(--surface-elevated),+ var(--text-primary) 16%+ );+ }+ button:disabled {+ opacity: 0.55;+ cursor: default;+ }+ button.primary {+ background: var(--surface-chip);+ border-color: var(--surface-chip);+ }+ button.primary:hover:not(:disabled) {+ background: color-mix(+ in srgb,+ var(--surface-chip),+ var(--text-primary) 8%+ );+ }+ button.ghost {+ background: transparent;+ border-color: transparent;+ }+ button.small {+ min-height: 28px;+ padding: 2px 10px;+ font-size: 12px;+ line-height: 20px;+ }+ .icon-button {+ padding: 0;+ width: 32px;+ height: 32px;+ flex-shrink: 0;+ }+ .icon-button.small {+ width: 28px;+ height: 28px;+ min-height: 28px;+ padding: 0;+ }+ :focus-visible {+ outline: 2px solid var(--focus-ring);+ outline-offset: 3px;+ }+ svg {+ width: 16px;+ height: 16px;+ fill: none;+ stroke: currentColor;+ stroke-width: 1.6;+ stroke-linecap: round;+ stroke-linejoin: round;+ flex-shrink: 0;+ vertical-align: middle;+ }+ h1,+ h2,+ h3,+ p {+ margin: 0;+ }+ h1,+ h2,+ h3 {+ font-weight: 500;+ }+ .muted {+ color: var(--text-secondary);+ }+ .micro {+ font-size: 12px;+ line-height: 20px;+ }+ .row {+ display: flex;+ align-items: center;+ gap: 8px;+ }+ .grow {+ flex: 1;+ min-width: 0;+ }+ .ellipsis {+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+ }+ code {+ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;+ font-size: 12px;+ background: var(--surface-chip);+ border-radius: 4px;+ padding: 1px 5px;+ overflow-wrap: anywhere;+ }+ /* ---------- prototype bar ---------- */+ .prototype {+ min-height: 56px;+ padding: 8px 20px;+ border-bottom: 1px solid var(--border-default);+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: 16px;+ background: var(--surface-elevated);+ }+ .prototype-title {+ font-size: 13px;+ font-weight: 500;+ }+ .prototype-note {+ font-size: 11px;+ color: var(--text-secondary);+ }+ .prototype-controls {+ display: flex;+ align-items: center;+ gap: 8px;+ flex-wrap: wrap;+ }+ select,+ input[type="text"] {+ height: 34px;+ border: 1px solid var(--border-default);+ background: var(--surface-elevated);+ border-radius: 9999px;+ padding: 5px 12px;+ font-size: 13px;+ max-width: 100%;+ }+ .prototype select {+ height: 32px;+ width: 210px;+ }+ .scene-help {+ min-height: 40px;+ border-top: 1px solid var(--border-default);+ padding: 9px 20px;+ background: var(--surface-elevated);+ font-size: 12px;+ line-height: 20px;+ color: var(--text-secondary);+ display: flex;+ align-items: center;+ gap: 8px;+ }+ /* ---------- app frame ---------- */+ .app {+ display: grid;+ grid-template-columns: 220px minmax(0, 1fr) minmax(380px, 460px);+ height: calc(100dvh - 96px);+ min-height: 620px;+ }+ .sidebar {+ padding: 18px 12px 12px;+ border-right: 1px solid var(--border-default);+ display: flex;+ flex-direction: column;+ min-height: 0;+ }+ .brand {+ font-size: 20px;+ font-weight: 500;+ letter-spacing: -0.8px;+ padding: 0 12px 18px;+ }+ .brand small {+ font-size: 11px;+ letter-spacing: 0;+ margin-left: 8px;+ color: var(--text-secondary);+ font-weight: 400;+ }+ .nav-label {+ margin: 20px 12px 6px;+ font-size: 12px;+ color: var(--text-secondary);+ }+ .nav-item {+ width: 100%;+ justify-content: flex-start;+ text-align: left;+ min-height: 36px;+ background: transparent;+ border: 0;+ padding: 7px 12px;+ font-weight: 400;+ border-radius: 10px;+ }+ .nav-item.selected {+ background: var(--surface-chip);+ font-weight: 500;+ }+ .nav-sub {+ padding: 0 12px 4px 36px;+ font-size: 11px;+ line-height: 18px;+ color: var(--text-secondary);+ }+ .nav-spacer {+ flex: 1;+ min-height: 30px;+ }+ .device-row {+ padding: 6px 12px;+ display: flex;+ align-items: center;+ gap: 9px;+ font-size: 12px;+ }+ .dot {+ width: 6px;+ height: 6px;+ border-radius: 50%;+ background: var(--status-success);+ flex-shrink: 0;+ }+ .dot.off {+ background: var(--text-tertiary);+ }+ .dot.run {+ background: var(--status-running);+ }+ .dot.err {+ background: var(--status-error);+ }+ .pane {+ min-width: 0;+ min-height: 0;+ display: flex;+ flex-direction: column;+ }+ .pane-header {+ min-height: 56px;+ display: flex;+ align-items: center;+ gap: 10px;+ padding: 10px 24px;+ border-bottom: 1px solid var(--border-default);+ }+ .pane-header h1 {+ font-size: 14px;+ line-height: 22px;+ }+ .chip {+ display: inline-flex;+ align-items: center;+ gap: 5px;+ font-size: 11px;+ line-height: 18px;+ color: var(--text-secondary);+ }+ .chip svg {+ width: 13px;+ height: 13px;+ }+ .tag {+ display: inline-flex;+ align-items: center;+ gap: 4px;+ font-size: 11px;+ line-height: 18px;+ padding: 0 7px;+ border-radius: 9999px;+ background: var(--surface-chip);+ color: var(--text-secondary);+ white-space: nowrap;+ }+ .tag svg {+ width: 12px;+ height: 12px;+ }+ .messages {+ flex: 1;+ overflow: auto;+ padding: 26px 28px 18px;+ scrollbar-gutter: stable;+ }+ .thread {+ width: min(100%, 700px);+ margin: 0 auto;+ }+ .time-divider {+ text-align: center;+ font-size: 11px;+ color: var(--text-secondary);+ margin-bottom: 22px;+ }+ .user-message {+ margin: 0 0 24px auto;+ max-width: 560px;+ width: fit-content;+ border-radius: 12px;+ background: var(--surface-chip);+ padding: 11px 15px;+ font-size: 14px;+ line-height: 24px;+ overflow-wrap: anywhere;+ }+ .msg-source {+ display: flex;+ align-items: center;+ gap: 5px;+ font-size: 11px;+ line-height: 18px;+ color: var(--text-secondary);+ margin-bottom: 4px;+ }+ .msg-source svg {+ width: 12px;+ height: 12px;+ }+ .assistant-label {+ display: flex;+ gap: 7px;+ align-items: center;+ margin-bottom: 8px;+ font-size: 12px;+ font-weight: 500;+ }+ .assistant-label svg {+ width: 14px;+ height: 14px;+ }+ .assistant-text {+ line-height: 25px;+ margin-bottom: 14px;+ overflow-wrap: anywhere;+ }+ .tool {+ border: 1px solid var(--border-default);+ border-radius: 10px;+ background: var(--surface-elevated);+ padding: 9px 12px;+ margin: 0 0 12px;+ font-size: 12px;+ line-height: 20px;+ }+ .tool-head {+ display: flex;+ align-items: center;+ gap: 7px;+ }+ .tool-head svg {+ width: 14px;+ height: 14px;+ }+ .tool-body {+ margin-top: 4px;+ color: var(--text-secondary);+ overflow-wrap: anywhere;+ }+ .tool.error .tool-state {+ color: var(--status-error);+ }+ .tool.ok .tool-state {+ color: var(--status-success);+ }+ .report {+ border-left: 2px solid var(--border-default);+ padding: 2px 0 2px 14px;+ margin: 6px 0 18px;+ }+ .report-head {+ display: flex;+ align-items: center;+ gap: 6px;+ flex-wrap: wrap;+ font-size: 12px;+ line-height: 20px;+ color: var(--text-secondary);+ margin-bottom: 4px;+ }+ .report-head b {+ color: var(--text-primary);+ font-weight: 500;+ }+ .notice {+ display: flex;+ gap: 8px;+ align-items: flex-start;+ font-size: 12px;+ line-height: 20px;+ color: var(--text-secondary);+ margin: 0 0 16px;+ }+ .notice svg {+ width: 14px;+ height: 14px;+ margin-top: 3px;+ }+ .notice.warn {+ color: var(--status-running);+ }+ .notice.error {+ color: var(--status-error);+ }+ .composer-wrap {+ padding: 10px 24px 16px;+ }+ .composer {+ background: var(--surface-elevated);+ border: 1px solid var(--border-default);+ border-radius: 12px;+ padding: 8px 10px;+ width: min(100%, 720px);+ margin: 0 auto;+ }+ .composer textarea {+ width: 100%;+ min-height: 40px;+ max-height: 120px;+ border: 0;+ padding: 4px;+ background: transparent;+ resize: none;+ font-size: 14px;+ line-height: 22px;+ outline: none;+ }+ .composer-tools {+ display: flex;+ justify-content: space-between;+ align-items: center;+ gap: 8px;+ margin-top: 2px;+ }+ .composer-note {+ text-align: center;+ font-size: 11px;+ line-height: 18px;+ color: var(--text-secondary);+ margin-top: 6px;+ }+ /* ---------- collab panel ---------- */+ .collab {+ border-left: 1px solid var(--border-default);+ background: color-mix(+ in srgb,+ var(--surface),+ var(--surface-elevated) 40%+ );+ }+ .rsb-tabs {+ height: 40px;+ display: flex;+ align-items: center;+ gap: 4px;+ padding: 0 10px;+ border-bottom: 1px solid var(--border-default);+ font-size: 12px;+ }+ .rsb-tabs span {+ padding: 3px 10px;+ border-radius: 9999px;+ color: var(--text-secondary);+ }+ .rsb-tabs span.on {+ background: var(--surface-chip);+ color: var(--text-primary);+ font-weight: 500;+ }+ .worker-strip {+ display: flex;+ align-items: center;+ gap: 4px;+ min-height: 40px;+ padding: 4px 8px;+ border-bottom: 1px solid var(--border-default);+ overflow-x: auto;+ }+ .worker-tab {+ min-height: 30px;+ padding: 2px 10px;+ font-size: 12px;+ font-weight: 400;+ border-color: transparent;+ background: transparent;+ white-space: nowrap;+ gap: 6px;+ }+ .worker-tab[aria-selected="true"] {+ background: var(--surface-chip);+ font-weight: 500;+ }+ .worker-tab svg {+ width: 13px;+ height: 13px;+ }+ .worker-tab .where {+ color: var(--text-secondary);+ font-weight: 400;+ }+ .worker-tab.archived {+ text-decoration: line-through;+ color: var(--text-tertiary);+ }+ .worker-info {+ padding: 10px 14px;+ border-bottom: 1px solid var(--border-default);+ display: grid;+ gap: 6px;+ font-size: 12px;+ line-height: 20px;+ }+ .worker-info .row {+ flex-wrap: wrap;+ gap: 6px 10px;+ }+ .status {+ display: inline-flex;+ align-items: center;+ gap: 5px;+ white-space: nowrap;+ color: var(--text-secondary);+ }+ .status.running,+ .status.waiting {+ color: var(--status-running);+ }+ .status.done {+ color: var(--status-success);+ }+ .status.error {+ color: var(--status-error);+ }+ .status .dot {+ background: currentColor;+ }+ .collab .messages {+ padding: 18px 16px 12px;+ }+ .collab .user-message {+ font-size: 13px;+ line-height: 22px;+ max-width: 92%;+ }+ .collab .assistant-text {+ font-size: 13px;+ line-height: 23px;+ }+ .collab .composer-wrap {+ padding: 8px 12px 12px;+ }+ .approval {+ border: 1px solid var(--status-running);+ border-radius: 12px;+ background: var(--surface-elevated);+ padding: 12px 14px;+ margin: 0 0 14px;+ font-size: 13px;+ line-height: 22px;+ }+ .approval .actions {+ display: flex;+ gap: 6px;+ flex-wrap: wrap;+ margin-top: 10px;+ }+ .empty {+ height: 100%;+ display: grid;+ place-items: center;+ text-align: center;+ padding: 24px;+ color: var(--text-secondary);+ font-size: 13px;+ }+ /* ---------- dialog ---------- */+ dialog {+ color: var(--text-primary);+ background: var(--surface-elevated);+ border: 1px solid var(--border-default);+ border-radius: 16px;+ padding: 0;+ max-height: 90dvh;+ width: min(500px, calc(100vw - 24px));+ overflow: auto;+ }+ dialog::backdrop {+ background: var(--overlay);+ }+ .dialog-header {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: 12px;+ padding: 16px 20px 6px;+ }+ .dialog-header h2 {+ font-size: 15px;+ }+ .dialog-content {+ padding: 6px 20px 8px;+ display: grid;+ gap: 16px;+ }+ .dialog-actions {+ display: flex;+ justify-content: flex-end;+ gap: 8px;+ padding: 8px 20px 18px;+ }+ .field-label {+ font-size: 12px;+ line-height: 20px;+ color: var(--text-secondary);+ margin-bottom: 6px;+ display: flex;+ align-items: center;+ gap: 6px;+ }+ .pills {+ display: flex;+ flex-wrap: wrap;+ gap: 6px;+ }+ .pills button {+ min-height: 28px;+ padding: 2px 12px;+ font-size: 12px;+ font-weight: 400;+ }+ .pills button[aria-checked="true"] {+ background: var(--surface-chip);+ border-color: var(--surface-chip);+ font-weight: 500;+ }+ .device-list {+ display: grid;+ gap: 4px;+ }+ .device-option {+ width: 100%;+ justify-content: flex-start;+ border-radius: 10px;+ border-color: var(--border-default);+ padding: 7px 12px;+ font-weight: 400;+ gap: 10px;+ text-align: left;+ }+ .device-option[aria-checked="true"] {+ border-color: var(--text-secondary);+ background: var(--surface-chip);+ font-weight: 500;+ }+ .device-option small {+ margin-left: auto;+ font-size: 11px;+ color: var(--text-secondary);+ font-weight: 400;+ white-space: nowrap;+ }+ .hint {+ font-size: 11px;+ line-height: 18px;+ color: var(--text-secondary);+ margin-top: 6px;+ }+ .field-error {+ font-size: 12px;+ line-height: 20px;+ color: var(--status-error);+ margin-top: 6px;+ }+ .dialog-content select,+ .dialog-content input[type="text"] {+ width: 100%;+ color: var(--text-primary);+ }+ .dialog-content textarea {+ width: 100%;+ height: 92px;+ resize: none;+ border: 1px solid var(--border-default);+ border-radius: 12px;+ background: transparent;+ padding: 9px 13px;+ font-size: 13px;+ line-height: 21px;+ color: var(--text-primary);+ }+ .seg {+ display: inline-flex;+ border: 1px solid var(--border-default);+ border-radius: 9999px;+ padding: 2px;+ gap: 2px;+ }+ .seg button {+ min-height: 26px;+ border: 0;+ padding: 1px 12px;+ font-size: 12px;+ font-weight: 400;+ background: transparent;+ }+ .seg button[aria-checked="true"] {+ background: var(--surface-chip);+ font-weight: 500;+ }+ .toast {+ position: fixed;+ bottom: 56px;+ left: 50%;+ transform: translateX(-50%);+ padding: 9px 16px;+ border: 1px solid var(--border-default);+ border-radius: 12px;+ background: var(--surface-elevated);+ font-size: 13px;+ z-index: 5;+ max-width: 90vw;+ }+ .mobile-switch {+ display: none;+ }+ [hidden] {+ display: none !important;+ }+ @media (max-width: 1100px) {+ .app {+ grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);+ }+ .sidebar {+ display: none;+ }+ }+ @media (max-width: 760px) {+ .app {+ grid-template-columns: 1fr;+ height: calc(100dvh - 176px);+ }+ .app[data-view="lead"] .collab,+ .app[data-view="collab"] .lead {+ display: none;+ }+ .collab {+ border-left: 0;+ }+ .mobile-switch {+ display: flex;+ justify-content: center;+ padding: 8px 14px;+ border-bottom: 1px solid var(--border-default);+ }+ .prototype {+ flex-wrap: wrap;+ padding: 8px 14px;+ gap: 8px;+ }+ .prototype-note {+ display: none;+ }+ .prototype-controls {+ width: 100%;+ }+ .prototype select {+ flex: 1;+ min-width: 0;+ width: auto;+ }+ .pane-header {+ padding: 10px 16px;+ }+ .messages {+ padding: 18px 14px;+ }+ .composer-wrap {+ padding: 8px 14px 12px;+ }+ .scene-help {+ padding: 8px 14px;+ align-items: flex-start;+ }+ }+ @media (prefers-reduced-motion: reduce) {+ *,+ *::before,+ *::after {+ transition: none !important;+ }+ }+ </style>+ </head>+ <body>+ <header class="prototype">+ <div>+ <div class="prototype-title">+ 协同 · Worker 跨设备运行+ <span class="muted">/ 交互原型 03</span>+ </div>+ <div class="prototype-note">+ 演示数据,不连接设备。Lead 在 XD-PC,Worker「转写」在 Mac mini 运行+ </div>+ </div>+ <div class="prototype-controls">+ <select id="scene" aria-label="演示场景">+ <option value="create">01 · 创建 Worker:选运行设备</option>+ <option value="running" selected>02 · 远端 Worker 运行中</option>+ <option value="approval">03 · 远端需要授权确认</option>+ <option value="offline">04 · Mac mini 断线</option>+ <option value="reconnected">05 · 重新连上,补发回报</option>+ <option value="reported">06 · 回报送达,Lead 继续</option>+ <option value="interject">07 · 在 Mac mini 上插话</option>+ <option value="dispatchFail">08 · 派活时 Mac mini 离线</option>+ <option value="leadStopped">09 · Lead 已停止,回报保留</option>+ <option value="archived">10 · 归档远端 Worker</option>+ <option value="targetView">11 · Mac mini 上看到的样子</option>+ </select>+ <button+ id="theme"+ class="icon-button"+ aria-label="切换深色模式"+ title="切换深色模式"+ ></button>+ <button+ id="reset"+ class="icon-button"+ aria-label="重置演示"+ title="重置演示"+ ></button>+ </div>+ </header>+ <div class="mobile-switch" id="mobile-switch">+ <div class="seg" role="radiogroup" aria-label="显示区域">+ <button role="radio" data-mobile="lead" aria-checked="false">+ Lead</button+ ><button role="radio" data-mobile="collab" aria-checked="true">+ 协同+ </button>+ </div>+ </div>+ <div class="app" id="app" data-view="collab">+ <aside class="sidebar" aria-label="任务列表" id="sidebar"></aside>+ <main class="pane lead" id="lead"></main>+ <aside class="pane collab" id="collab" aria-label="协同"></aside>+ </div>+ <footer class="scene-help">+ <span data-icon="info"></span><span id="scene-help"></span>+ </footer>++ <dialog id="create" aria-labelledby="create-title">+ <header class="dialog-header">+ <h2 id="create-title">创建新 Worker</h2>+ <button+ class="icon-button ghost small"+ data-close="create"+ aria-label="关闭创建 Worker 弹窗"+ title="关闭"+ >+ ×+ </button>+ </header>+ <div class="dialog-content" id="create-content"></div>+ <div class="dialog-actions">+ <button data-close="create">取消</button>+ <button class="primary" id="create-submit">创建 Worker</button>+ </div>+ </dialog>++ <dialog id="archive" aria-labelledby="archive-title">+ <header class="dialog-header">+ <h2 id="archive-title">归档 Worker 转写?</h2>+ </header>+ <div class="dialog-content">+ <p class="micro">+ 它会从这个协同里移除,并停止 Mac mini 上正在进行的这一轮。Mac mini+ 上的任务、记录和文件都会保留,标注「协同已结束」,可以在那台继续查看。+ </p>+ </div>+ <div class="dialog-actions">+ <button data-close="archive">取消</button>+ <button id="archive-confirm">归档 Worker</button>+ </div>+ </dialog>+ <div id="toast" class="toast" role="status" hidden></div>++ <script>+ const $ = (s) => document.querySelector(s);+ const paths = {+ info: "M12 11v6M12 7h.01M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0",+ moon: "M20 15A9 9 0 0 1 9 3a9 9 0 1 0 11 12",+ sun: "M12 2v2M12 20v2M2 12h2M20 12h2M5 5l1.5 1.5M17.5 17.5 19 19M5 19l1.5-1.5M17.5 6.5 19 5M16 12a4 4 0 1 1-8 0 4 4 0 0 1 8 0",+ reset: "M3 10a9 9 0 1 1 1 7M3 4v6h6",+ spark: "M12 3l2.5 6.5L21 12l-6.5 2.5L12 21l-2.5-6.5L3 12l6.5-2.5z",+ monitor: "M4 3h16v12H4zM8 21h8M12 15v6",+ laptop: "M5 4h14v12H5zM2 20h20l-3-4H5z",+ message:+ "M5 4h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H9l-5 3v-3H3V6a2 2 0 0 1 2-2Z",+ plus: "M12 5v14M5 12h14",+ up: "M12 19V5M5 12l7-7 7 7",+ tool: "M14 6l4 4M4 20l7-7M15 3l6 6-9 9-6-6z",+ folder: "M3 7V4h6l3 3h9v13H3z",+ shield: "M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6z",+ link: "M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1",+ offline:+ "M3 3l18 18M8.5 16.5a5 5 0 0 1 7 0M5 12.9a10 10 0 0 1 5-2.7M19 12.9a10 10 0 0 0-2.3-1.6M12 20h.01",+ reply: "M9 14 4 9l5-5M4 9h11a5 5 0 0 1 5 5v6",+ stop: "M7 7h10v10H7z",+ archive: "M3 4h18v4H3zM5 8v12h14V8M10 12h4",+ users:+ "M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM2 21v-1a6 6 0 0 1 12 0v1M16 3.1a4 4 0 0 1 0 7.8M22 21v-1a6 6 0 0 0-4-5.7",+ };+ const icon = (n) =>+ '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="' ++ (paths[n] || paths.info) ++ '"/></svg>';+ const esc = (v) =>+ String(v).replace(+ /[&<>"']/g,+ (c) =>+ ({+ "&": "&",+ "<": "<",+ ">": ">",+ '"': """,+ "'": "'",+ })[c],+ );+ document+ .querySelectorAll("[data-icon]")+ .forEach((el) => (el.innerHTML = icon(el.dataset.icon)));+ $("#theme").innerHTML = icon("moon");+ $("#reset").innerHTML = icon("reset");++ const HERE = "XD-PC";+ const DEVICES = [+ { id: "local", name: "这台电脑", detail: "XD-PC", icon: "laptop" },+ { id: "macmini", name: "Mac mini", detail: "在线", icon: "monitor" },+ { id: "office", name: "工作电脑", detail: "在线", icon: "monitor" },+ {+ id: "old",+ name: "旧笔记本",+ detail: "版本过旧,需更新",+ icon: "monitor",+ disabled: true,+ },+ ];+ const MODELS = {+ local: ["Claude Sonnet 5", "Claude Opus 5.5"],+ macmini: [+ "Claude Opus 5.5 · Mac mini 的订阅",+ "Claude Sonnet 5 · Mac mini 的订阅",+ ],+ office: ["GPT-5.5 · 工作电脑的 API key"],+ };+ const deviceName = (id) =>+ id === "local" ? HERE : DEVICES.find((d) => d.id === id).name;++ const STATUS = {+ running: ["运行中", "running"],+ waiting: ["待确认", "waiting"],+ unreachable: ["无法获取状态", ""],+ done: ["已回报", "done"],+ idle: ["空闲", ""],+ archived: ["已归档", ""],+ };+ const TASK =+ "转写 ~/Interviews/2026-10-09.mp4,区分说话人 A / B,生成完整逐字稿和带时间点的摘要,两份 Markdown 放在同目录。完成后告诉我文件路径和摘要要点。";++ const HELP = {+ create:+ "运行设备默认「这台电脑」。只列出同账号、在线、开启了「允许远程控制」的电脑;版本过旧的不可选。选其他电脑后,模型按那台可用的列出,工作目录也指那台上的目录。",+ running:+ "Worker 的任务、目录、命令都在 Mac mini。标签上标出设备;点开看到的是 Mac mini 上的任务,可以直接发消息。",+ approval:+ "远端的授权确认在这里也能处理,Mac mini 上同样可见,先处理的生效。Lead 的标签上出现待处理提醒。",+ offline: "断线不判失败、不重派。保留最后已知状态,等重新连上后核对。",+ reconnected:+ "重连后读取 Mac mini 上任务的真实状态:断线期间已完成的那一轮,补发回报给 Lead,只发一次。",+ reported:+ "回报沿用现有协同自动回报:取 Worker 这一轮的最后回复,送进 Lead 队列,Lead 被唤起后继续。",+ interject:+ "在 Mac mini 上直接给这个任务发的消息按插话处理:Worker 照常回复,但不算 Lead 派活,不会回报给 Lead。",+ dispatchFail:+ "派活时目标电脑离线,直接失败并告诉 Lead,不排队等对方上线,避免 Lead 误以为已经派出。",+ leadStopped:+ "Lead 停止后,远端 Worker 不受影响;回报保留在 Lead 队列里,不会自动启动 Lead。",+ archived:+ "归档只把 Worker 移出协同并停止当前一轮;Mac mini 上的任务和文件保留,标注协同已结束。",+ targetView:+ "Mac mini 上,这个任务出现在侧栏,标注来自 XD-PC 的协同,显示实际权限档;不能在这里再开启协同或复制到其他电脑。",+ };++ const fresh = () => ({+ scene: "running",+ focused: "transcribe",+ workers: [+ {+ id: "frontend",+ name: "前端",+ device: "local",+ status: "running",+ agent: "Codex",+ model: "GPT-5.5",+ perm: "自动审批",+ dir: "D:/projects/report-site",+ },+ {+ id: "transcribe",+ name: "转写",+ device: "macmini",+ status: "running",+ agent: "Claude Code",+ model: "Claude Opus 5.5 · Mac mini 的订阅",+ perm: "自动审批",+ dir: "/Users/demo/Interviews",+ },+ ],+ leadStopped: false,+ form: null,+ sent: [],+ });+ let state = fresh();+ let toastTimer;+ function toast(t) {+ clearTimeout(toastTimer);+ $("#toast").textContent = t;+ $("#toast").hidden = false;+ toastTimer = setTimeout(() => ($("#toast").hidden = true), 3200);+ }+ const W = (id) => state.workers.find((w) => w.id === id);+ const sceneIs = (...s) => s.includes(state.scene);++ function applyScene(s) {+ state = fresh();+ state.scene = s;+ const t = W("transcribe");+ if (s === "approval") t.status = "waiting";+ if (s === "offline" || s === "dispatchFail") t.status = "unreachable";+ if (s === "reconnected" || s === "reported" || s === "leadStopped")+ t.status = "done";+ if (s === "interject") t.status = "running";+ if (s === "leadStopped") state.leadStopped = true;+ if (s === "archived") t.status = "archived";+ if (s === "create") {+ state.workers = state.workers.filter((w) => w.id !== "transcribe");+ state.focused = "frontend";+ }+ render();+ if (s === "create") openCreate();+ }++ /* ---------- sidebar ---------- */+ function renderSidebar() {+ const target = state.scene === "targetView";+ $("#sidebar").innerHTML =+ '<div class="brand">Cindy <small>' ++ (target ? "Mac mini" : HERE) ++ "</small></div>" ++ '<div class="nav-label">任务</div>' ++ (target+ ? '<button class="nav-item">' ++ icon("message") ++ '<span class="ellipsis">整理家庭照片</span></button>' ++ '<button class="nav-item selected">' ++ icon("users") ++ '<span class="ellipsis">Worker · 转写</span></button>' ++ '<div class="nav-sub">来自 XD-PC 的协同</div>'+ : '<button class="nav-item selected">' ++ icon("message") ++ '<span class="ellipsis">整理产品访谈报告</span></button>' ++ '<div class="nav-sub">协同 · ' ++ state.workers.filter((w) => w.status !== "archived").length ++ " 个 Worker</div>" ++ '<button class="nav-item">' ++ icon("message") ++ '<span class="ellipsis">周报</span></button>') ++ '<div class="nav-spacer"></div><div class="nav-label">已连接的电脑</div>' ++ '<div class="device-row">' ++ icon(target ? "monitor" : "laptop") ++ '<span class="grow">' ++ (target ? "Mac mini" : HERE) ++ '</span><span class="muted">本机</span></div>' ++ '<div class="device-row">' ++ icon(target ? "laptop" : "monitor") ++ '<span class="grow">' ++ (target ? HERE : "Mac mini") ++ '</span><span class="dot' ++ (sceneIs("offline", "dispatchFail") ? " off" : "") ++ '"></span></div>' ++ '<div class="device-row">' ++ icon("monitor") ++ '<span class="grow">工作电脑</span><span class="dot"></span></div>';+ }++ /* ---------- lead pane ---------- */+ function toolCard(name, body, stateText, cls = "ok") {+ return (+ '<div class="tool ' ++ cls ++ '"><div class="tool-head">' ++ icon("tool") ++ "<code>" ++ esc(name) ++ '</code><span class="grow"></span><span class="tool-state">' ++ esc(stateText) ++ '</span></div><div class="tool-body">' ++ body ++ "</div></div>"+ );+ }+ function cindy(text) {+ return (+ '<div class="assistant-label">' ++ icon("spark") ++ 'Cindy · Lead</div><p class="assistant-text">' ++ text ++ "</p>"+ );+ }+ function reportBlock(extra = "") {+ return (+ '<div class="report"><div class="report-head">' ++ icon("reply") ++ '<b>Worker 转写</b><span class="tag">' ++ icon("monitor") ++ "Mac mini</span><span>回报</span>" ++ extra ++ '</div><p class="micro">已生成 <code>~/Interviews/2026-10-09-逐字稿.md</code> 和 <code>~/Interviews/2026-10-09-摘要.md</code>。摘要要点:多设备交接成本高;希望交出后不必盯着另一台电脑;需要清楚的状态。</p></div>'+ );+ }+ function renderLead() {+ const s = state.scene;+ if (s === "targetView") {+ renderTargetMain();+ return;+ }+ let html =+ '<div class="time-divider">今天 · 10:20</div><div class="user-message">把今天的产品访谈整理成报告页面。录音在 Mac mini 的 ~/Interviews 里,转写放在 Mac mini 上跑;页面在这台电脑上先搭起来。</div>';+ if (s === "create") {+ html +=+ cindy(+ "好。我先在这台电脑上建前端 Worker 搭页面。转写需要放到 Mac mini 上,你可以在右侧「协同」里创建,或者让我来建。",+ ) ++ toolCard(+ "create_worker",+ "前端 · 运行设备:这台电脑 · Codex",+ "已创建",+ );+ } else {+ html +=+ cindy(+ "好,分给两个 Worker:转写在 Mac mini 上跑,前端在这台电脑上搭页面。",+ ) ++ toolCard(+ "create_worker",+ "转写 · 运行设备:<b>Mac mini</b> · 目录 <code>/Users/demo/Interviews</code> · Claude Code",+ "已创建",+ ) ++ toolCard(+ "create_worker",+ "前端 · 运行设备:这台电脑 · Codex",+ "已创建",+ ) ++ '<p class="assistant-text">两个 Worker 都已派活,等它们回报。</p>';+ }+ if (s === "approval")+ html +=+ '<div class="notice warn">' ++ icon("shield") ++ "<span>Worker 转写(Mac mini)在等待授权确认,可在右侧「协同」里处理。</span></div>";+ if (s === "offline")+ html +=+ '<div class="notice">' ++ icon("offline") ++ "<span>暂时无法获取 Mac mini 的状态。Worker 转写保留最后已知状态「运行中」,重新连上后核对。</span></div>";+ if (s === "reconnected")+ html +=+ '<div class="notice">' ++ icon("link") ++ "<span>已重新连上 Mac mini。断线期间 Worker 转写已完成一轮,补发回报 1 条。</span></div>" ++ reportBlock('<span class="muted">· 断线期间完成</span>') ++ cindy(+ "逐字稿收到了。我先对照摘要列出报告的章节,再交给前端 Worker 填页面。",+ );+ if (s === "reported")+ html +=+ reportBlock() ++ cindy(+ "逐字稿收到了。我先对照摘要列出报告的章节,再交给前端 Worker 填页面。",+ ) ++ toolCard(+ "send_to_worker",+ "→ 前端:按 5 个章节搭页面骨架,引用摘要里的三个要点。",+ "已派活",+ );+ if (s === "interject")+ html +=+ '<p class="micro muted" style="margin-bottom:16px">你在 Mac mini 上给 Worker 转写发了消息。按插话处理,不会回报到这里。</p>';+ if (s === "dispatchFail")+ html +=+ '<div class="user-message">让转写也把受访者提到的产品名单独列出来。</div>' ++ toolCard(+ "send_to_worker",+ "→ 转写:补充要求「把受访者提到的产品名单独列出来」<br>Mac mini 不可达(离线),消息没有发出。",+ "失败",+ "error",+ ) ++ cindy(+ "Mac mini 现在离线,这条补充要求没有发出去。等它重新连上后,你再让我发一次,或者先改由这台电脑上的 Worker 处理。",+ );+ if (s === "leadStopped")+ html +=+ '<div class="notice">' ++ icon("stop") ++ "<span>Lead 已停止。Worker 转写(Mac mini)的回报已保留在队列里,恢复 Lead 后再处理,不会自动开始。</span></div>";+ if (s === "archived")+ html +=+ '<div class="notice">' ++ icon("archive") ++ "<span>Worker 转写已归档。Mac mini 上的任务和文件仍保留。</span></div>";+ state.sent+ .filter((m) => m.to === "lead")+ .forEach(+ (m) =>+ (html += '<div class="user-message">' + esc(m.text) + "</div>"),+ );++ const stopped = state.leadStopped;+ $("#lead").innerHTML =+ '<header class="pane-header"><div class="grow"><h1>整理产品访谈报告</h1><span class="chip">' ++ icon("laptop") ++ HERE ++ " · Lead</span></div>" ++ '<span class="status ' ++ (stopped ? "" : "running") ++ '"><span class="dot"></span>' ++ (stopped+ ? "已停止"+ : sceneIs("reported", "reconnected")+ ? "运行中"+ : "等待 Worker 回报") ++ "</span></header>" ++ '<section class="messages" aria-label="Lead 消息"><div class="thread">' ++ html ++ "</div></section>" ++ '<div class="composer-wrap"><div class="composer"><textarea id="lead-input" aria-label="发给 Lead" placeholder="给 Lead 发消息…"></textarea><div class="composer-tools"><span class="chip">Claude Code · Claude Sonnet 5 · 协同</span><div class="row">' ++ (stopped+ ? '<button class="small" data-action="resume-lead">恢复 Lead</button>'+ : "") ++ '<button class="primary icon-button small" data-send="lead" aria-label="发送">' ++ icon("up") ++ "</button></div></div></div></div>";+ }++ /* ---------- collab pane ---------- */+ function workerTab(w) {+ const [label, tone] = STATUS[w.status];+ const remote = w.device !== "local";+ return (+ '<button role="tab" class="worker-tab' ++ (w.status === "archived" ? " archived" : "") ++ '" data-focus="' ++ w.id ++ '" aria-selected="' ++ (state.focused === w.id) ++ '" aria-label="Worker ' ++ esc(w.name) ++ "," ++ esc(deviceName(w.device)) ++ "," ++ label ++ '">' ++ '<span class="dot ' ++ (tone === "running" || tone === "waiting"+ ? "run"+ : tone === "done"+ ? ""+ : tone === "error"+ ? "err"+ : "off") ++ '"></span>' ++ esc(w.name) ++ (remote+ ? '<span class="where">' ++ icon("monitor") ++ esc(deviceName(w.device)) ++ "</span>"+ : "") ++ "</button>"+ );+ }+ function workerThread(w) {+ if (w.id === "frontend")+ return (+ '<div class="user-message"><div class="msg-source">' ++ icon("reply") ++ "来自 Lead</div>在 D:/projects/report-site 搭报告页面骨架:标题区、章节导航、引用卡片。</div>" ++ '<div class="assistant-label">' ++ icon("spark") ++ 'Worker 前端</div><p class="assistant-text">已建好页面骨架和三个组件,正在接入示例数据。</p>'+ );+ const s = state.scene;+ let h =+ '<div class="user-message"><div class="msg-source">' ++ icon("reply") ++ "来自 Lead(XD-PC)</div>" ++ esc(TASK) ++ "</div>" ++ '<div class="assistant-label">' ++ icon("spark") ++ "Worker 转写</div>" ++ '<p class="assistant-text">先确认录音格式,再分段转写。</p>' ++ toolCard(+ "Bash",+ "<code>ffprobe ~/Interviews/2026-10-09.mp4</code> · 在 Mac mini 上运行",+ "完成",+ );+ if (s === "approval") {+ h +=+ '<div class="approval" role="group" aria-label="授权确认"><div class="row">' ++ icon("shield") ++ '<b class="grow">需要确认</b><span class="tag">' ++ icon("monitor") ++ "Mac mini</span></div>" ++ '<p style="margin-top:6px">Worker 转写想在 Mac mini 上运行:</p><p><code>pip install --user faster-whisper</code></p>' ++ '<p class="micro muted" style="margin-top:6px">在这里或 Mac mini 上处理都可以,先处理的生效。</p>' ++ '<div class="actions"><button class="primary small" data-action="approve">允许一次</button><button class="small" data-action="deny">拒绝</button></div></div>';+ return h;+ }+ h += toolCard(+ "Bash",+ "<code>whisper-run --diarize ~/Interviews/2026-10-09.mp4</code> · 在 Mac mini 上运行",+ sceneIs("running", "offline", "interject", "dispatchFail")+ ? "运行中"+ : "完成",+ sceneIs("running", "offline", "interject", "dispatchFail")+ ? ""+ : "ok",+ );+ if (s === "interject")+ h +=+ '<div class="user-message"><div class="msg-source">' ++ icon("monitor") ++ "你在 Mac mini 上发送 · 插话,不回报给 Lead</div>顺便把背景噪音大的片段标出来。</div>" ++ '<div class="assistant-label">' ++ icon("spark") ++ 'Worker 转写</div><p class="assistant-text">好,转写时会把噪音较大的片段标为「[听不清]」并附时间点。</p>';+ if (sceneIs("reconnected", "reported", "leadStopped", "archived"))+ h +=+ '<div class="assistant-label">' ++ icon("spark") ++ 'Worker 转写</div><p class="assistant-text">完成。逐字稿和摘要已写到 <code>~/Interviews/</code>:<br>· 2026-10-09-逐字稿.md<br>· 2026-10-09-摘要.md<br>摘要要点:多设备交接成本高;希望交出后不必盯着另一台电脑;需要清楚的状态。</p>' ++ (s === "archived"+ ? ""+ : '<p class="micro muted">' ++ icon("reply") ++ " 已作为回报送给 Lead" ++ (s === "leadStopped" ? "(Lead 已停止,排队中)" : "") ++ "</p>");+ state.sent+ .filter((m) => m.to === w.id)+ .forEach((m) => {+ h +=+ '<div class="user-message"><div class="msg-source">' ++ icon("laptop") ++ "你在 XD-PC 上发送 · 插话,不回报给 Lead</div>" ++ esc(m.text) ++ "</div>";+ });+ return h;+ }+ function renderCollab() {+ if (state.scene === "targetView") {+ $("#collab").innerHTML =+ '<div class="rsb-tabs"><span class="on">任务信息</span><span>文件</span></div>' ++ '<div class="worker-info"><div class="row"><span class="tag">' ++ icon("users") ++ "来自 XD-PC 的协同</span></div>" ++ '<dl style="margin:6px 0 0;display:grid;grid-template-columns:72px 1fr;gap:6px 10px">' ++ '<dt class="muted">Lead</dt><dd style="margin:0">XD-PC · 整理产品访谈报告</dd>' ++ '<dt class="muted">权限</dt><dd style="margin:0">自动审批<br><span class="muted">沿用 XD-PC 的 Worker 创建偏好</span></dd>' ++ '<dt class="muted">目录</dt><dd style="margin:0"><code>/Users/demo/Interviews</code></dd>' ++ '<dt class="muted">回报</dt><dd style="margin:0">Lead 派的活完成后自动回报给 XD-PC;你在这里发的消息不回报</dd></dl>' ++ '<div class="row" style="margin-top:8px"><button class="small" disabled title="这是协同里的 Worker,不能再开启协同">开启协同</button><button class="small" disabled title="协同 Worker 不能复制到其他电脑">复制到其他电脑</button></div></div>';+ return;+ }+ const w = W(state.focused);+ const remote = w && w.device !== "local";+ let info = "";+ if (w) {+ const [label, tone] = STATUS[w.status];+ info =+ '<div class="worker-info"><div class="row"><span class="status ' ++ tone ++ '"><span class="dot"></span>' ++ label ++ "</span>" ++ '<span class="tag">' ++ icon(remote ? "monitor" : "laptop") ++ (remote+ ? "在 " + esc(deviceName(w.device)) + " 上运行"+ : "这台电脑") ++ "</span>" ++ '<span class="grow"></span>' ++ (w.status !== "archived"+ ? '<button class="ghost icon-button small" data-action="stop-worker" aria-label="停止 Worker 当前一轮" title="停止当前一轮">' ++ icon("stop") ++ '</button><button class="ghost icon-button small" data-action="archive-worker" aria-label="归档 Worker" title="归档 Worker">' ++ icon("archive") ++ "</button>"+ : "") ++ '</div><div class="row muted"><span>' ++ icon("folder") ++ " <code>" ++ esc(w.dir) ++ "</code></span><span>" ++ esc(w.agent) ++ " · " ++ esc(w.model) ++ "</span><span>" ++ icon("shield") ++ " " ++ esc(w.perm) ++ "</span></div>" ++ (w.status === "unreachable"+ ? '<div class="notice" style="margin:4px 0 0">' ++ icon("offline") ++ "<span>Mac mini 已断线。最后已知状态:运行中。不会判为失败,也不会重派。</span></div>"+ : "") ++ (w.status === "archived"+ ? '<div class="notice" style="margin:4px 0 0">' ++ icon("archive") ++ "<span>已从协同归档。Mac mini 上的任务和文件保留。</span></div>"+ : "") ++ "</div>";+ }+ const offline = w && w.status === "unreachable";+ const inactive = !w || w.status === "archived";+ $("#collab").innerHTML =+ '<div class="rsb-tabs"><span>文件</span><span class="on">协同</span><span>浏览器</span></div>' ++ '<div class="worker-strip" role="tablist" aria-label="Workers">' ++ state.workers.map(workerTab).join("") ++ '<button class="ghost icon-button small" data-action="open-create" aria-label="创建新 Worker" title="创建新 Worker">' ++ icon("plus") ++ "</button></div>" ++ info ++ '<section class="messages" aria-label="Worker 消息"><div class="thread">' ++ (w ? workerThread(w) : '<div class="empty">等待 Worker</div>') ++ "</div></section>" ++ '<div class="composer-wrap"><div class="composer"><textarea id="worker-input" aria-label="发给 Worker" ' ++ (offline || inactive ? "disabled " : "") ++ 'placeholder="' ++ (inactive+ ? "Worker 已归档"+ : offline+ ? "Mac mini 离线,暂时无法发送"+ : "给 " ++ esc(w.name) ++ " 发消息" ++ (remote+ ? "(在 " + esc(deviceName(w.device)) + " 上执行)"+ : "") ++ "…") ++ '"></textarea><div class="composer-tools"><span class="chip">' ++ (w ? esc(w.agent) : "") ++ '</span><button class="primary icon-button small" data-send="worker" aria-label="发送" ' ++ (offline || inactive ? "disabled" : "") ++ ">" ++ icon("up") ++ "</button></div></div>" ++ '<p class="composer-note">直接发给 Worker 的消息按插话处理,不会回报给 Lead。</p></div>';+ }+ function renderTargetMain() {+ const w = W("transcribe");+ $("#lead").innerHTML =+ '<header class="pane-header"><div class="grow"><h1>Worker · 转写</h1><span class="chip">' ++ icon("monitor") ++ 'Mac mini · 来自 XD-PC 的协同</span></div><span class="status running"><span class="dot"></span>运行中</span></header>' ++ '<section class="messages"><div class="thread">' ++ workerThread(w) ++ "</div></section>" ++ '<div class="composer-wrap"><div class="composer"><textarea aria-label="发给 Worker" placeholder="在这里直接发消息…"></textarea><div class="composer-tools"><span class="chip">Claude Code · Claude Opus 5.5 · 自动审批</span><button class="primary icon-button small" aria-label="发送" data-send="target">' ++ icon("up") ++ '</button></div></div><p class="composer-note">在这里发的消息按插话处理,不会回报给 XD-PC 上的 Lead。</p></div>';+ }++ /* ---------- create dialog ---------- */+ function openCreate() {+ state.form = {+ role: "转写",+ custom: "",+ device: "macmini",+ agent: "Claude Code",+ model: MODELS.macmini[0],+ perm: "自动审批",+ dirMode: "auto",+ dir: "/Users/demo/Interviews",+ task: TASK,+ error: "",+ };+ renderCreate();+ if (!$("#create").open) $("#create").showModal();+ }+ function renderCreate() {+ const f = state.form;+ const remote = f.device !== "local";+ const dn = deviceName(f.device);+ $("#create-content").innerHTML =+ '<div><div class="field-label">角色名</div><div class="pills" role="radiogroup" aria-label="角色名">' ++ ["开发", "审查", "测试", "转写"]+ .map(+ (r) =>+ '<button role="radio" data-role="' ++ r ++ '" aria-checked="' ++ (f.role === r) ++ '">' ++ r ++ "</button>",+ )+ .join("") ++ "</div></div>" ++ '<div><div class="field-label">运行设备</div><div class="device-list" role="radiogroup" aria-label="运行设备">' ++ DEVICES.map(+ (d) =>+ '<button role="radio" class="device-option" data-device="' ++ d.id ++ '" aria-checked="' ++ (f.device === d.id) ++ '"' ++ (d.disabled ? " disabled" : "") ++ ">" ++ icon(d.icon) ++ "<span>" ++ esc(d.name) ++ "</span><small>" ++ esc(d.detail) ++ "</small></button>",+ ).join("") ++ '</div><p class="hint">离线或未开启「允许远程控制」的电脑不显示。' ++ (remote ? "Worker 的任务、目录和命令都在 " + esc(dn) + "。" : "") ++ "</p></div>" ++ (remote+ ? '<div><div class="field-label">' ++ esc(dn) ++ ' 上的工作目录</div><div class="seg" role="radiogroup" aria-label="工作目录"><button role="radio" data-dirmode="auto" aria-checked="' ++ (f.dirMode === "auto") ++ '">自动分配</button><button role="radio" data-dirmode="path" aria-checked="' ++ (f.dirMode === "path") ++ '">指定目录</button></div>' ++ (f.dirMode === "path"+ ? '<input type="text" id="f-dir" style="margin-top:8px" value="' ++ esc(f.dir) ++ '" placeholder="/Users/…/project" aria-label="' ++ esc(dn) ++ ' 上的目录" />'+ : "") ++ '<p class="hint">' ++ (f.dirMode === "auto"+ ? "由 " + esc(dn) + " 按自己的设置分配任务目录。"+ : "在 " ++ esc(dn) ++ " 上检查;不存在时报错,不会换成这台电脑的目录。") ++ "</p></div>"+ : "") ++ '<div><div class="field-label">Agent</div><div class="seg" role="radiogroup" aria-label="Agent">' ++ ["Claude Code", "Codex", "Pi"]+ .map(+ (a) =>+ '<button role="radio" data-agent="' ++ a ++ '" aria-checked="' ++ (f.agent === a) ++ '">' ++ a ++ "</button>",+ )+ .join("") ++ "</div></div>" ++ '<div><label class="field-label" for="f-model">模型</label><select id="f-model">' ++ MODELS[f.device]+ .map(+ (m) =>+ "<option" ++ (m === f.model ? " selected" : "") ++ ">" ++ esc(m) ++ "</option>",+ )+ .join("") ++ "</select>" ++ (remote+ ? '<p class="hint">按 ' ++ esc(dn) ++ " 上已连接的模型列出,使用那台的登录和供应商。</p>"+ : "") ++ "</div>" ++ '<div><label class="field-label" for="f-perm">权限模式</label><select id="f-perm"><option' ++ (f.perm === "自动审批" ? " selected" : "") ++ ">自动审批</option><option" ++ (f.perm === "完全访问" ? " selected" : "") ++ ">完全访问</option></select>" ++ (remote+ ? '<p class="hint">沿用这台电脑的 Worker 创建偏好;' ++ esc(dn) ++ " 上会显示实际权限。</p>"+ : "") ++ "</div>" ++ '<div><label class="field-label" for="f-task">初始任务 <span class="muted">(可选)</span></label><textarea id="f-task" placeholder="给这个 Worker 的可选第一条任务">' ++ esc(f.task) ++ "</textarea>" ++ (remote+ ? '<p class="hint">原样发到 ' + esc(dn) + " 上的 Worker 任务。</p>"+ : "") ++ "</div>" ++ (f.error+ ? '<p class="field-error" role="alert">' + esc(f.error) + "</p>"+ : "");+ $("#create-submit").textContent = remote+ ? "在 " + dn + " 上创建"+ : "创建 Worker";+ }+ function submitCreate() {+ const f = state.form;+ f.task = $("#f-task").value;+ if ($("#f-dir")) f.dir = $("#f-dir").value.trim();+ const remote = f.device !== "local";+ if (remote && f.dirMode === "path") {+ if (!/^(\/|~\/|[a-zA-Z]:[\\/])/.test(f.dir))+ f.error = "请输入 " + deviceName(f.device) + " 上的绝对路径。";+ else if (/missing|不存在/i.test(f.dir))+ f.error =+ deviceName(f.device) ++ " 上找不到这个目录:" ++ f.dir ++ "。Worker 未创建。";+ else f.error = "";+ if (f.error) {+ renderCreate();+ return;+ }+ }+ const id = "w" + Date.now();+ state.workers.push({+ id,+ name: f.role,+ device: f.device,+ status: "running",+ agent: f.agent,+ model: f.model,+ perm: f.perm,+ dir: remote+ ? f.dirMode === "auto"+ ? "~/Cindy/对话/2026-10-09/" + f.role+ : f.dir+ : "D:/projects/report-site",+ });+ if (f.role === "转写" && !W("transcribe"))+ state.workers[state.workers.length - 1].id = "transcribe";+ state.focused = state.workers[state.workers.length - 1].id;+ $("#create").close();+ render();+ toast(+ remote+ ? "已在 " ++ deviceName(f.device) ++ " 上创建 Worker「" ++ f.role ++ "」"+ : "已创建 Worker「" + f.role + "」",+ );+ }++ function render() {+ $("#scene").value = state.scene;+ $("#scene-help").textContent = "演示说明 · " + HELP[state.scene];+ const target = state.scene === "targetView";+ $('[data-mobile="lead"]').textContent = target ? "任务" : "Lead";+ $('[data-mobile="collab"]').textContent = target ? "任务信息" : "协同";+ renderSidebar();+ renderLead();+ renderCollab();+ }++ /* ---------- events ---------- */+ document.addEventListener("click", (e) => {+ const c = e.target.closest("[data-close]");+ if (c) return $("#" + c.dataset.close).close();+ const f = e.target.closest("[data-focus]");+ if (f) {+ state.focused = f.dataset.focus;+ return renderCollab();+ }+ const m = e.target.closest("[data-mobile]");+ if (m) {+ $("#app").dataset.view = m.dataset.mobile;+ document+ .querySelectorAll("[data-mobile][role=radio]")+ .forEach((b) => b.setAttribute("aria-checked", String(b === m)));+ return;+ }+ if (state.form && $("#create").open) {+ const r = e.target.closest("[data-role]");+ const d = e.target.closest("[data-device]");+ const a = e.target.closest("[data-agent]");+ const dm = e.target.closest("[data-dirmode]");+ if (r) state.form.role = r.dataset.role;+ if (d && !d.disabled) {+ state.form.device = d.dataset.device;+ state.form.model = MODELS[d.dataset.device][0];+ state.form.error = "";+ }+ if (a) state.form.agent = a.dataset.agent;+ if (dm) state.form.dirMode = dm.dataset.dirmode;+ if (r || d || a || dm) {+ state.form.task = $("#f-task").value;+ if ($("#f-dir")) state.form.dir = $("#f-dir").value;+ return renderCreate();+ }+ }+ const s = e.target.closest("[data-send]");+ if (s) {+ const box =+ s.dataset.send === "lead"+ ? $("#lead-input")+ : s.dataset.send === "worker"+ ? $("#worker-input")+ : $("#lead textarea");+ const text = box.value.trim();+ if (!text) return box.focus();+ if (s.dataset.send === "target") {+ toast("演示:在 Mac mini 上发送,按插话处理,不回报给 Lead。");+ box.value = "";+ return;+ }+ state.sent.push({+ to: s.dataset.send === "lead" ? "lead" : state.focused,+ text,+ });+ render();+ if (s.dataset.send === "worker")+ toast("已发给 Worker,按插话处理,不会回报给 Lead。");+ return;+ }+ const el = e.target.closest("[data-action]");+ if (!el) return;+ const act = el.dataset.action;+ if (act === "open-create") openCreate();+ if (act === "approve" || act === "deny") {+ W("transcribe").status = "running";+ state.scene = "running";+ render();+ toast(+ act === "approve"+ ? "已允许,Mac mini 上继续执行。"+ : "已拒绝,Worker 会换一种方式继续。",+ );+ }+ if (act === "stop-worker") {+ const w = W(state.focused);+ if (w.status === "unreachable")+ return toast("Mac mini 离线,停止请求发不出去;重新连上后再试。");+ w.status = "idle";+ renderCollab();+ toast(+ "已停止 " ++ w.name ++ " 的当前一轮" ++ (w.device !== "local" ? ",Mac mini 上的任务保留" : "") ++ "。",+ );+ }+ if (act === "archive-worker") {+ const w = W(state.focused);+ $("#archive-title").textContent = "归档 Worker " + w.name + "?";+ $("#archive").showModal();+ }+ if (act === "resume-lead") {+ state.leadStopped = false;+ state.scene = "reported";+ render();+ toast("Lead 已恢复,开始处理保留的回报。");+ }+ });+ $("#archive-confirm").addEventListener("click", () => {+ const w = W(state.focused);+ w.status = "archived";+ $("#archive").close();+ render();+ toast(+ w.device !== "local"+ ? "已归档。Mac mini 上的任务和文件保留。"+ : "已归档。",+ );+ });+ $("#create-submit").addEventListener("click", submitCreate);+ document.addEventListener("change", (e) => {+ if (!state.form) return;+ if (e.target.id === "f-model") state.form.model = e.target.value;+ if (e.target.id === "f-perm") state.form.perm = e.target.value;+ });+ $("#scene").addEventListener("change", (e) => applyScene(e.target.value));+ $("#theme").addEventListener("click", () => {+ const dark = document.documentElement.dataset.theme !== "dark";+ document.documentElement.dataset.theme = dark ? "dark" : "light";+ $("#theme").innerHTML = icon(dark ? "sun" : "moon");+ const label = dark ? "切换浅色模式" : "切换深色模式";+ $("#theme").setAttribute("aria-label", label);+ $("#theme").title = label;+ });+ $("#reset").addEventListener("click", () => {+ document.querySelectorAll("dialog[open]").forEach((d) => d.close());+ applyScene("running");+ });+ render();+ </script>+ </body>+</html>diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.mdindex 144a0abd62..8c5e26e512 100644--- a/docs/dev-rules/protocol-compatibility.md+++ b/docs/dev-rules/protocol-compatibility.md@@ -603,6 +603,26 @@ handler 无 sender 依赖;不加入共享任务访客白名单,不进入自- **暂不支持**:分叉、审查、移动项目、复制到其他电脑、导出 `.cshare`(Agent 会话记录在 B),入口隐藏、主进程拒绝。+## 协同远端 Worker:Worker 在另一台电脑运行++与上一节方向相反:协同的 Lead 与团队留在 A,单个 Worker 的任务、目录、命令与文件都在 B(运行设备)。+B 上的 Worker 是一条普通任务,`sessions.orca_remote_lead`(migration 0124,JSON 见+`apps/desktop/src/shared/orcaRemoteWorker.ts`)记录派活电脑与 Lead;派活、停止与回报复用现有会话通道。+方案与产品决策见 [`../orca-cross-device-worker-plan.md`](../orca-cross-device-worker-plan.md)。++- **新增 channel**(`packages/device-link/src/orcaRemoteWorker.ts`,只进同账号 allowlist,不进共享任务清单):+ `maker:orca:remote-worker:caps`(能力探测,回 `{ version }`)、`…:open`(按 A 给定的任务 id 新建 Worker 任务,+ 幂等;超时 60s)、`…:release`(结束协同,任务与文件保留,幂等)。B 侧实现见+ `apps/desktop/src/main/maker-ipc/orcaRemoteWorkerHost.ts`。+- **来源身份**:派活电脑取 server 盖章的 `src`(`DeviceLinkInvokeContext.controllerDeviceId`),不采信载荷自报;+ 非 device-link 调用与共享任务访客一律拒绝。`open` 指定的 `workingDir` 与 `maker:create-session` 同口径经+ B 的目录守卫(`device-link/dispatch.ts` 的 `PATH_GUARDED_CHANNELS`);不指定则由 B 分配任务目录。+- **旧端降级**:旧版 B 没有这三个 channel,回 `CHANNEL_NOT_ALLOWED`;A 据此把该电脑显示为「需要更新」,+ **不回退**到普通 `maker:create-session`(普通任务没有防嵌套与来源标记)。B 新、A 旧时 B 不受影响。+- **B 侧约束**:带标记的任务不能再开启协同(`assertLeadCollabProjectEnabled` 统一拒绝 Worker 与远端 Worker,+ 覆盖 IPC、远程与 Agent 工具入口),不能复制到其他电脑(`task-migration/service.ts`);侧栏照常显示,+ 任务头标注「来自 X 的协同」,结束后显示「协同已结束」。+## 事实来源| 内容 | 权威来源 |diff --git a/docs/orca-cross-device-worker-plan.md b/docs/orca-cross-device-worker-plan.mdnew file mode 100644index 0000000000..9792e9cdf7--- /dev/null+++ b/docs/orca-cross-device-worker-plan.md@@ -0,0 +1,156 @@+# 协同扩展:Worker 在另一台电脑运行++> 状态:产品决策已定(2026-10-09,见 §5),分三步实现,不是产品规则。+> 第一步(运行设备侧支持与 schema)已落地,协议见 `docs/dev-rules/protocol-compatibility.md`+> 「协同远端 Worker」;Lead 侧编排与界面落地后再拆入 `docs/dev-rules/orca-team-architecture.md`。+> 来源讨论:issue #5620「远程控制功能疑问」→ 跨设备派活。++## 1. 结论++跨设备派活不再单独做一套「委托」,改为扩展协同(Orca):**Lead 留在发起的电脑,单个 Worker+可以指定在同账号的另一台电脑上运行**。Worker 的任务、工作目录、命令和文件都在那台电脑;+团队、派活记录与回报仍归 Lead 所在的电脑。++这样可直接复用协同已有的派活、自动回报、排队、打断、完成判定和协同面板,用户只需理解一套协同。++交互原型:`docs/design-previews/cross-device-delegation/index.html`(协同面板版)。+此前「独立委托」的两版原型(聊天派发、输入框选设备)已被本方案取代,不入库。++## 2. 现状核对++| 问题 | 现状 | 依据 |+| -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |+| Worker 能否指定其他主机或电脑 | 不能。Worker 一律继承 Lead 的位置 | `orcaWorkerCreationService.ts` 的 `OrcaLeadSessionSnapshot` 与 worker 创建参数 |+| SSH 远端 | Worker 继承 Lead 的 `remoteHostId`,在同一台远端主机运行 | `orca-team-architecture.md` |+| 远程控制(device-link) | Lead、Worker、团队全部在被控端,控制端只是镜像 | 同上 |+| `create_worker` 的 `working_dir` | 只能选「Worker 所在主机」,即 Lead 所在的机器 | 同上 |+| 已有的「远程 Agent」 | 只借用另一台电脑的 Agent 程序、登录与供应商;**命令与文件仍在本机**。Worker 继承 Lead 的 `agentDeviceId`,不能单独指定 | `protocol-compatibility.md`「远程 Agent」;`orcaWorkerCreationService.ts` |+| 被控的电脑能否同时控制另一台 | 能。远程 Agent 就是 A 作为发起方驱动 B;当前开发会话即为实例:XD-PC 被手机控制,同时把 Agent 放在另一台电脑运行 | `apps/desktop/src/main/remote-agent/controller/` |+| 在另一台电脑新建任务、发消息、订阅事件的通道 | 已在同账号 allowlist:`maker:create-session`、`maker:send`、`maker:abort-session`、`maker:input:*`、`maker:event`、`maker:mark-orca-role` 等 | `packages/device-link/src/allowlist.ts` |++**需要分清两个概念**,界面文案必须区分:++- **Agent 所在电脑**(已有):模型与登录在那台,干活还在本机。+- **Worker 运行设备**(本方案新增):整个 Worker 任务在那台运行,包括目录、命令和文件。++本方案首版不允许两者叠加。++## 3. 用户看到的行为++### 3.1 创建++- **手动创建**:协同面板的「创建 Worker」卡增加「运行设备」,默认「这台电脑」。列表只显示+ 同账号、在线、已开启「允许远程控制」且版本支持的电脑;版本过旧的显示为不可选,并提示更新。+- **Lead 创建**:`create_worker` / `create_workers` 增加可选参数 `device`,取值必须来自新增的只读+ 工具或 `get_workspace_info` 返回的设备列表(设备 id),由程序校验在线状态、版本与授权,不接受+ 名称模糊匹配。模型只能在已列出的设备里选,不能自行描述设备。+- 选择其他设备时,`working_dir` 指那台电脑上的目录:不填则由那台按自身设置分配任务目录;+ 填写则在那台检查,不存在或不可用时报错,不换目录、不回退到本机。+- 初始任务原样发给那台的 Worker 任务。手动入口由用户书写;Lead 入口由 Lead 书写,+ 与本机 Worker 一致。++### 3.2 运行中++- 协同面板的 Worker 行显示设备名与连接状态,例如「Mac mini · 运行中」。+- 点开 Worker 查看的是那台电脑上的任务,复用现有远程任务视图。+- Worker 需要授权确认时,在 Lead 所在电脑可见并可处理,沿用远程任务的确认链路;+ 那台电脑本机同样能看到。+- 目标电脑上,这个任务出现在侧栏,标注「来自 XD-PC 的协同」,按 Worker 处理:+ 不能再开启协同,不能复制到其他电脑;显示实际权限档(沿用 A 的 Worker 创建偏好)。+- 用户可以在目标电脑上直接给这个任务发消息,按用户插话处理,不算 Lead 派活、不产生回报。++### 3.3 回报与继续++- Worker 一轮结束后,沿用 auto-bridge:取那台任务的最后回复,作为回报送入 Lead 队列,+ Lead 被唤起后继续。Lead 忙时排队;Lead 已停止时回报保留,不自动启动。+- 「团队是否完成」沿用 Main 的待回报判据:远端 Worker 的派活同样登记待回报,+ 回报送达或被丢弃后才算完成。+- 同一轮结果重复到达只送一次,以远端轮次标识去重。++### 3.4 断线与停止++| 情况 | 行为 |+| -------------------- | ----------------------------------------------------------------------- |+| 目标电脑离线 | Worker 显示「暂时无法获取状态」,保留最后已知状态;不判失败、不重派 |+| 重新连上 | 读取远端任务实际状态与最后回复,补发缺失的回报,已送达的不重复 |+| 派活时目标离线 | 派活直接失败并告知 Lead,不排队等对方上线(首版) |+| `idle_worker` / 停止 | 停止远端当前轮,远端任务与记录保留 |+| `archive_worker` | 归档团队里的 Worker;远端任务保留,标注协同已结束,由用户在那台自行处理 |+| 停止 Lead | 不影响远端 Worker 运行,回报保留 |++## 4. 技术方案++### 4.1 归属++- 团队、Worker 记录、待回报和派活队列都在 **Lead 所在电脑**(以下称 A)。+- Worker 的任务在**运行设备**(以下称 B)上,是一条普通任务,带 `sessions.orca_remote_lead` 标记。+ 不复用 `orca_role='worker'`:那会把任务从 B 的侧栏隐藏,且 B 上没有对应的 `orca_workers` 关联。+- A 以同账号控制端的身份驱动 B,与远程 Agent 的方向一致。+- 用户从手机或另一台桌面控制 A 时,仍由 A 编排;控制端只看到 A 推送的 Worker 变化,+ 新增的设备字段为可选,旧控制端忽略即可。++### 4.2 复用的通道++建任务与结束协同用新增 channel(裸 `local-db:sessions:create` 不开放远程,普通+`maker:create-session` 无法写来源标记);其余组合已有同账号 channel:++| 动作 | 通道 |+| --------------------- | ------------------------------------------------------------------------------------ |+| 能力探测 | `maker:orca:remote-worker:caps`(旧版 → `CHANNEL_NOT_ALLOWED` → 显示需要更新) |+| 在 B 创建 Worker 任务 | `maker:orca:remote-worker:open`(幂等;来源取 server 盖章的 src) |+| 结束协同 | `maker:orca:remote-worker:release` |+| 派活、补充 | `maker:input:enqueue`(按 `item.clientId` 幂等,`maker:input:get-projection` 查回执) |+| 打断、停止 | `maker:input:stop`、`maker:abort-session` |+| 运行状态与轮次结束 | `sessions` topic 的 `local-db:sessions:activity` |+| 最后回复 | `local-db:history:messages`(assistant、倒序、取 1 条) |+| 授权确认 | 现有远程任务确认链路 |++### 4.3 A 侧改动++- **数据**:Orca Worker 记录新增 `execution_device_id`(空 = 本机)与远端任务 id,需新 migration,+ 旧版本读不到时按本机 Worker 处理。改动前读 `database-and-migrations.md`。+- **创建**:`orcaWorkerCreationService` 增加设备分支:校验设备(在线、版本、同账号、非共享访客)、+ 在 B 校验目录、创建任务并标记角色。与 `remoteHostId`、`agentDeviceId` 互斥,冲突时报错。+- **派活**:`orcaTeamService` 的私有 dispatch 路径按 Worker 位置分到本机适配器或远端适配器;+ accepted 回调、clientId、持久化与 `activeWorkerDispatches` 计数保持同一套,不另造状态机。+- **回报**:远端轮次结束事件触发 auto-bridge;待回报按远端轮次标识幂等。+- **恢复**:每台设备一个订阅;断线按 `remote-and-mobile-adaptation.md` 的「故障半径三问」,+ 只影响该设备上的 Worker,不重建 link、不影响其它设备和普通远控。+- **工具**:`create_worker` / `create_workers` 新增 `device`;新增或扩展只读工具返回可选设备;+ 归属校验 `resolveWorkerRef` 不变。++### 4.4 首版不支持++- 远端 Worker 主动调用 `send_to_lead`。它在 B 上,没有到 A 的 Worker 桥;只靠 auto-bridge 回报,+ 与 SSH 多实例降级时一致。后续可经新 channel 补上。+- 文件交接(见 §5 决策 1)。+- 远端 Worker 与 SSH 主机、远程 Agent 混用。+- 共享任务访客创建远端 Worker。+- Mobile 作为运行设备(手机不运行 Agent)。++## 5. 已定决策(2026-10-09)++1. **文件交接不进首版。** 首版只处理运行设备上已有的文件;「本机文件交给另一台处理、成果传回」+ 放到第二阶段,届时沿用此前定下的交接语义:传的是副本、校验通过才开始、成果显式列出后回传。+2. **用户在 B 上直接给 Worker 任务发消息:允许。** 按用户插话处理,不算 Lead 派活,+ 不登记待回报,也不单独触发回报;回报只跟 Lead 的派活走。+3. **派活时 B 离线:直接失败。** 告知 Lead 与用户设备不可达,不排队等对方上线。+4. **权限档沿用 A 的 Worker 创建偏好**,与本机 Worker 同一套规则;B 上的任务显示实际权限档。+5. **不新增授权开关。** B 开启「允许远程控制」即可被选为运行设备;未开启的电脑不出现在列表里。++## 6. 分期++| 阶段 | 内容 |+| ---- | ------------------------------------------------------------------------------------------------------ |+| 一 | 桌面对桌面、同账号;手动与 Lead 两个入口;目录在目标电脑;auto-bridge 回报;断线对账;协同面板显示设备 |+| 二 | 文件交接与成果回传;远端 `send_to_lead`;手机控制端展示设备信息 |+| 三 | 视需要:派活离线排队、SSH 与设备混用 |++## 7. 实现前必读++- `docs/dev-rules/orca-team-architecture.md`+- `docs/dev-rules/protocol-compatibility.md`(远程 Agent、device-link allowlist)+- `docs/dev-rules/remote-and-mobile-adaptation.md`(故障半径三问)+- `docs/dev-rules/database-and-migrations.md`+- `docs/product-rules/task-device-migration.md`(跨电脑任务的既有口径)+- 界面改动:`docs/design-rules/DESIGN.md`;术语:`i18n/GLOSSARY.md`(「设备」「远程电脑」「Worker」「Lead」)diff --git a/packages/device-link/src/__tests__/orcaRemoteWorker.test.ts b/packages/device-link/src/__tests__/orcaRemoteWorker.test.tsnew file mode 100644index 0000000000..79a18a1a8b--- /dev/null+++ b/packages/device-link/src/__tests__/orcaRemoteWorker.test.ts@@ -0,0 +1,86 @@+import { describe, expect, it } from 'vitest';+import {+ INVOKE_TIMEOUT_OVERRIDES_MS,+ ORCA_REMOTE_WORKER_CAPS_CHANNEL,+ ORCA_REMOTE_WORKER_OPEN_CHANNEL,+ ORCA_REMOTE_WORKER_OPEN_TIMEOUT_MS,+ ORCA_REMOTE_WORKER_RELEASE_CHANNEL,+ REMOTE_INVOKE_ALLOWLIST,+ parseOrcaRemoteWorkerOpenRequest,+ parseOrcaRemoteWorkerReleaseRequest,+} from '../index.js';++const base = {+ sessionId: 'w_remote_1',+ agentKind: 'claude-code',+ permissionMode: 'auto',+ title: 'Worker · 转写',+ lead: { leadSessionId: 'lead-1', leadTitle: '整理产品访谈报告', workerLabel: '转写' },+};++describe('orca remote worker channels', () => {+ // Shared-task guests are refused by the desktop shared-task gate (not in its channel list).+ it('registers caps / open / release on the same-account allowlist', () => {+ for (const channel of [+ ORCA_REMOTE_WORKER_CAPS_CHANNEL,+ ORCA_REMOTE_WORKER_OPEN_CHANNEL,+ ORCA_REMOTE_WORKER_RELEASE_CHANNEL,+ ]) {+ expect(REMOTE_INVOKE_ALLOWLIST.has(channel)).toBe(true);+ }+ });++ it('gives open a longer invoke budget than the default', () => {+ expect(INVOKE_TIMEOUT_OVERRIDES_MS[ORCA_REMOTE_WORKER_OPEN_CHANNEL]).toBe(+ ORCA_REMOTE_WORKER_OPEN_TIMEOUT_MS,+ );+ });+});++describe('parseOrcaRemoteWorkerOpenRequest', () => {+ it('keeps known fields, trims text and drops unknown fields', () => {+ expect(+ parseOrcaRemoteWorkerOpenRequest({+ ...base,+ model: ' claude-opus-5-5 ',+ workingDir: '/Users/demo/Interviews',+ fastMode: false,+ leadDeviceId: 'spoofed',+ extra: 1,+ }),+ ).toEqual({+ ...base,+ model: 'claude-opus-5-5',+ workingDir: '/Users/demo/Interviews',+ fastMode: false,+ });+ });++ it('treats blank optional fields as absent', () => {+ expect(parseOrcaRemoteWorkerOpenRequest({ ...base, model: ' ', workingDir: '' })).toEqual(base);+ });++ it.each([+ ['unsafe session id', { ...base, sessionId: '../x' }],+ ['unknown agent', { ...base, agentKind: 'gpt' }],+ ['unsupported permission mode', { ...base, permissionMode: 'ask' }],+ ['missing title', { ...base, title: ' ' }],+ ['missing lead', { ...base, lead: undefined }],+ ['unsafe lead session id', { ...base, lead: { ...base.lead, leadSessionId: 'a/b' } }],+ ['missing worker label', { ...base, lead: { ...base.lead, workerLabel: '' } }],+ ['working dir with newline', { ...base, workingDir: '/tmp/a\nb' }],+ ['non-boolean fastMode', { ...base, fastMode: 'yes' }],+ ])('rejects %s', (_name, input) => {+ expect(() => parseOrcaRemoteWorkerOpenRequest(input)).toThrow(/\[INVALID_PARAMS\]/);+ });+});++describe('parseOrcaRemoteWorkerReleaseRequest', () => {+ it('accepts a safe session id only', () => {+ expect(parseOrcaRemoteWorkerReleaseRequest({ sessionId: 'w_remote_1', x: 1 })).toEqual({+ sessionId: 'w_remote_1',+ });+ expect(() => parseOrcaRemoteWorkerReleaseRequest({ sessionId: 'a b' })).toThrow(/INVALID_PARAMS/);+ expect(() => parseOrcaRemoteWorkerReleaseRequest(null)).toThrow(/INVALID_PARAMS/);+ });+});diff --git a/packages/device-link/src/allowlist.ts b/packages/device-link/src/allowlist.tsindex 48f70b939d..f142d01b9f 100644--- a/packages/device-link/src/allowlist.ts+++ b/packages/device-link/src/allowlist.ts@@ -26,6 +26,12 @@*/import { FILE_PEER_CHANNEL } from './filePeer.js';import { REMOTE_AGENT_CHANNEL } from './remoteAgent.js';+import {+ ORCA_REMOTE_WORKER_CAPS_CHANNEL,+ ORCA_REMOTE_WORKER_OPEN_CHANNEL,+ ORCA_REMOTE_WORKER_OPEN_TIMEOUT_MS,+ ORCA_REMOTE_WORKER_RELEASE_CHANNEL,+} from './orcaRemoteWorker.js';import { TASK_MIGRATION_CHANNEL } from './taskMigration.js';import { SESSION_ACTIVITY_CHANNEL, SESSION_SYNC_CHANNEL } from './topics.js';import { REMOTE_DESKTOP_INVOKE_MS } from './remoteDesktopIce.js';@@ -406,6 +412,13 @@ const EXTENDED_INVOKE_CHANNELS: readonly string[] = ['local-db:orca-workflows:get-by-lead','local-db:orca-workflows:get-by-worker-session','local-db:orca-workflows:list-workers-by-lead',+ // 协同远端 Worker:本机作为运行设备,承接另一台电脑上 Lead 派来的 Worker 任务。+ // 准入同 maker:create-session:同账号 + 本机开启远程控制时控制端本就能在这里建任务;+ // 业务 handler 不依赖 sender、无本机 UI 副作用;来源电脑取 server 盖章的 src。+ // 老版本无 handler → CHANNEL_NOT_ALLOWED,控制端提示更新而不回退普通建任务。+ ORCA_REMOTE_WORKER_CAPS_CHANNEL,+ ORCA_REMOTE_WORKER_OPEN_CHANNEL,+ ORCA_REMOTE_WORKER_RELEASE_CHANNEL,// —— Rewind / Fork / Title / Context ——'maker:rewind:preview','maker:rewind:commit',@@ -795,6 +808,8 @@ export const INVOKE_TIMEOUT_OVERRIDES_MS: Readonly<Record<string, number>> = {// 被控端先等 Lead history 最多 30s,再 resume/queue Worker;默认 30s 会与服务端// deadline 对撞,把边沿成功误报成 DEVICE_LINK_TIMEOUT。留出派发和回程余量。'maker:worker:dispatch-ui-assignment': 65_000,+ // 运行设备准备工作目录并启动 Worker 的 Agent,可能超过默认 30s。+ [ORCA_REMOTE_WORKER_OPEN_CHANNEL]: ORCA_REMOTE_WORKER_OPEN_TIMEOUT_MS,// listing tier 轻量 DB 读:毫秒级查询,12s 仍等不到只能是链路问题,快速失败喂给熔断器。// 12s 同时覆盖被控端冷启动 DB 迁移的常见时长(那类失败是快速返回的 DbClient not ready,// 不吃满超时),不会误伤首拉重试。diff --git a/packages/device-link/src/index.ts b/packages/device-link/src/index.tsindex 297c2b21e7..bcdfb13996 100644--- a/packages/device-link/src/index.ts+++ b/packages/device-link/src/index.ts@@ -59,4 +59,5 @@ export * from "./pluginOauthAuthentication.js";export * from "./inputDelivery.js";export * from "./taskMigration.js";export * from "./remoteAgent.js";+export * from "./orcaRemoteWorker.js";export * from './pluginPages.js';diff --git a/packages/device-link/src/orcaRemoteWorker.ts b/packages/device-link/src/orcaRemoteWorker.tsnew file mode 100644index 0000000000..01c9822085--- /dev/null+++ b/packages/device-link/src/orcaRemoteWorker.ts@@ -0,0 +1,140 @@+/**+ * 协同远端 Worker(同账号):Lead 与团队留在发起电脑(控制端),单个 Worker 的任务、目录、+ * 命令与文件都在运行设备(被控端)上。运行设备上的 Worker 是一条普通任务,带「来自哪台+ * 电脑的协同」标记;派活、停止与回报复用现有会话通道,这里只登记运行设备新增的三个入口:+ *+ * - `caps`:能力探测。老版本没有该 channel → CHANNEL_NOT_ALLOWED,控制端据此提示更新,+ * 不回退到普通建任务(普通任务没有防嵌套与来源标记)。+ * - `open`:按控制端给定的 sessionId 新建 Worker 任务,幂等(同一控制端重复 open 返回同一任务)。+ * 来源电脑身份取 server 盖章的 src,不采信载荷自报。+ * - `release`:通知运行设备这个 Worker 已结束协同,任务与文件保留。幂等。+ */+export const ORCA_REMOTE_WORKER_CAPS_CHANNEL = 'maker:orca:remote-worker:caps';+export const ORCA_REMOTE_WORKER_OPEN_CHANNEL = 'maker:orca:remote-worker:open';+export const ORCA_REMOTE_WORKER_RELEASE_CHANNEL = 'maker:orca:remote-worker:release';+export const ORCA_REMOTE_WORKER_VERSION = 1;++/** 运行设备上 open 可能要准备工作目录并启动 Agent,给足执行与回程余量。 */+export const ORCA_REMOTE_WORKER_OPEN_TIMEOUT_MS = 60_000;++export const ORCA_REMOTE_WORKER_AGENT_KINDS = ['claude-code', 'codex', 'pi'] as const;+export type OrcaRemoteWorkerAgentKind = (typeof ORCA_REMOTE_WORKER_AGENT_KINDS)[number];++export const ORCA_REMOTE_WORKER_PERMISSION_MODES = ['auto', 'bypassPermissions'] as const;+export type OrcaRemoteWorkerPermissionMode =+ (typeof ORCA_REMOTE_WORKER_PERMISSION_MODES)[number];++export interface OrcaRemoteWorkerCaps {+ version: number;+}++export interface OrcaRemoteWorkerOpenRequest {+ /** 控制端生成的运行设备任务 id;同一 id 重复 open 幂等。 */+ sessionId: string;+ agentKind: OrcaRemoteWorkerAgentKind;+ /** 缺省 = 运行设备的默认模型与来源。 */+ model?: string;+ providerId?: string;+ effort?: string;+ fastMode?: boolean;+ permissionMode: OrcaRemoteWorkerPermissionMode;+ /** 运行设备上的绝对目录;缺省 = 运行设备按自身设置分配任务目录。 */+ workingDir?: string;+ title: string;+ lead: {+ leadSessionId: string;+ leadTitle: string;+ workerLabel: string;+ };+}++export interface OrcaRemoteWorkerOpenResult {+ sessionId: string;+ workingDir: string;+ model: string;+ agentKind: OrcaRemoteWorkerAgentKind;+}++export interface OrcaRemoteWorkerReleaseRequest {+ sessionId: string;+}++const SAFE_ID = /^[A-Za-z0-9_.:-]{1,128}$/;+const MAX_TEXT = 200;++function isRecord(value: unknown): value is Record<string, unknown> {+ return !!value && typeof value === 'object' && !Array.isArray(value);+}++function optString(value: unknown, max = MAX_TEXT): string | undefined {+ if (value === undefined || value === null) return undefined;+ if (typeof value !== 'string') throw new Error('[INVALID_PARAMS] expected string');+ const trimmed = value.trim();+ if (trimmed.length === 0) return undefined;+ if (trimmed.length > max) throw new Error('[INVALID_PARAMS] value too long');+ return trimmed;+}++function requiredString(value: unknown, field: string, max = MAX_TEXT): string {+ const parsed = optString(value, max);+ if (!parsed) throw new Error(`[INVALID_PARAMS] ${field} is required`);+ return parsed;+}++export function isOrcaRemoteWorkerSessionId(value: unknown): value is string {+ return typeof value === 'string' && SAFE_ID.test(value);+}++/** 运行设备侧权威校验:不认识的字段丢弃,类型不符一律 INVALID_PARAMS。 */+export function parseOrcaRemoteWorkerOpenRequest(raw: unknown): OrcaRemoteWorkerOpenRequest {+ if (!isRecord(raw)) throw new Error('[INVALID_PARAMS] open request must be an object');+ if (!isOrcaRemoteWorkerSessionId(raw.sessionId)) {+ throw new Error('[INVALID_PARAMS] sessionId must be a safe id');+ }+ const agentKind = raw.agentKind;+ if (!ORCA_REMOTE_WORKER_AGENT_KINDS.includes(agentKind as OrcaRemoteWorkerAgentKind)) {+ throw new Error('[INVALID_PARAMS] invalid agentKind');+ }+ const permissionMode = raw.permissionMode;+ if (!ORCA_REMOTE_WORKER_PERMISSION_MODES.includes(permissionMode as OrcaRemoteWorkerPermissionMode)) {+ throw new Error('[INVALID_PARAMS] invalid permissionMode');+ }+ if (raw.fastMode !== undefined && typeof raw.fastMode !== 'boolean') {+ throw new Error('[INVALID_PARAMS] fastMode must be boolean');+ }+ if (!isRecord(raw.lead)) throw new Error('[INVALID_PARAMS] lead is required');+ const leadSessionId = raw.lead.leadSessionId;+ if (!isOrcaRemoteWorkerSessionId(leadSessionId)) {+ throw new Error('[INVALID_PARAMS] lead.leadSessionId must be a safe id');+ }+ const workingDir = optString(raw.workingDir, 4096);+ if (workingDir && /[\r\n\0]/.test(workingDir)) {+ throw new Error('[INVALID_PARAMS] workingDir contains control characters');+ }+ const model = optString(raw.model);+ const providerId = optString(raw.providerId);+ const effort = optString(raw.effort, 32);+ return {+ sessionId: raw.sessionId,+ agentKind: agentKind as OrcaRemoteWorkerAgentKind,+ ...(model ? { model } : {}),+ ...(providerId ? { providerId } : {}),+ ...(effort ? { effort } : {}),+ ...(typeof raw.fastMode === 'boolean' ? { fastMode: raw.fastMode } : {}),+ permissionMode: permissionMode as OrcaRemoteWorkerPermissionMode,+ ...(workingDir ? { workingDir } : {}),+ title: requiredString(raw.title, 'title'),+ lead: {+ leadSessionId,+ leadTitle: optString(raw.lead.leadTitle) ?? '',+ workerLabel: requiredString(raw.lead.workerLabel, 'lead.workerLabel', 32),+ },+ };+}++export function parseOrcaRemoteWorkerReleaseRequest(raw: unknown): OrcaRemoteWorkerReleaseRequest {+ if (!isRecord(raw) || !isOrcaRemoteWorkerSessionId(raw.sessionId)) {+ throw new Error('[INVALID_PARAMS] sessionId must be a safe id');+ }+ return { sessionId: raw.sessionId };+}