Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
merge(main): 解决插件统计迁移与详情冲突
nanac7cd1107f3f2
diff --cc apps/desktop/drizzle/0128_demonic_odin.sqlindex 794c8fbb0e,0000000000..0a35d7728fmode 100644,000000..100644--- a/apps/desktop/drizzle/0128_demonic_odin.sql+++ b/apps/desktop/drizzle/0128_demonic_odin.sql@@@ -1,36 -1,0 +1,37 @@@+CREATE TABLE `plugin_usage_events` (+ `call_id` text PRIMARY KEY NOT NULL,+ `subject_id` text NOT NULL,+ `history_generation` integer NOT NULL,+ `occurred_at` integer NOT NULL,+ `tool_name` text NOT NULL,+ `session_id` text,+ `version` text,+ `release_id` text,+ `outcome` text DEFAULT 'unknown' NOT NULL,+ `report_target` text,+ `report_state` text DEFAULT 'not-applicable' NOT NULL,+ `next_attempt_at` integer,+ `attempt_count` integer DEFAULT 0 NOT NULL,+ FOREIGN KEY (`subject_id`) REFERENCES `plugin_usage_subjects`(`id`) ON UPDATE no action ON DELETE no action+);+--> statement-breakpoint+CREATE INDEX `plugin_usage_events_time_idx` ON `plugin_usage_events` (`subject_id`,`occurred_at`);--> statement-breakpoint+CREATE INDEX `plugin_usage_events_task_idx` ON `plugin_usage_events` (`subject_id`,`session_id`,`occurred_at`);--> statement-breakpoint++CREATE INDEX `plugin_usage_events_pending_idx` ON `plugin_usage_events` (`next_attempt_at`,`occurred_at`) WHERE "plugin_usage_events"."report_state" = 'pending';--> statement-breakpoint+CREATE TABLE `plugin_usage_subjects` (+ `id` text PRIMARY KEY NOT NULL,+ `stable_key` text,+ `source_kind` text NOT NULL,+ `plugin_id` text,+ `organization_id` text,+ `source_key` text,+ `server_root` text,+ `ghost_id` text NOT NULL,+ `display_name` text NOT NULL,+ `binding_revision` text,+ `recording_started_at` integer NOT NULL,+ `history_generation` integer DEFAULT 0 NOT NULL+);+--> statement-breakpoint+CREATE UNIQUE INDEX `plugin_usage_subjects_source_idx` ON `plugin_usage_subjects` (`stable_key`);--> statement-breakpoint+CREATE INDEX `plugin_usage_subjects_binding_idx` ON `plugin_usage_subjects` (`ghost_id`,`binding_revision`);diff --cc apps/desktop/drizzle/meta/0128_snapshot.jsonindex 0000000000,0000000000..e7089466b0new file mode 100644--- /dev/null+++ b/apps/desktop/drizzle/meta/0128_snapshot.json@@@ -1,0 -1,0 +1,7201 @@@++{++ "version": "6",++ "dialect": "sqlite",++ "id": "779b3cd5-66b5-40e9-a391-bacb00957c6f",++ "prevId": "d1fee593-4e19-434f-a63f-80f26c723017",++ "tables": {++ "account_usage_snapshots": {++ "name": "account_usage_snapshots",++ "columns": {++ "agent_kind": {++ "name": "agent_kind",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "snapshot": {++ "name": "snapshot",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "updated_at": {++ "name": "updated_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {},++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "agent_input_queue_snapshots": {++ "name": "agent_input_queue_snapshots",++ "columns": {++ "session_id": {++ "name": "session_id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "payload": {++ "name": "payload",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "updated_at": {++ "name": "updated_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {},++ "foreignKeys": {++ "agent_input_queue_snapshots_session_id_sessions_id_fk": {++ "name": "agent_input_queue_snapshots_session_id_sessions_id_fk",++ "tableFrom": "agent_input_queue_snapshots",++ "tableTo": "sessions",++ "columnsFrom": [++ "session_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "auto_review_projections": {++ "name": "auto_review_projections",++ "columns": {++ "session_id": {++ "name": "session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "lead_id": {++ "name": "lead_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "revision": {++ "name": "revision",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "projected_revision": {++ "name": "projected_revision",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": -1++ },++ "version": {++ "name": "version",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 1++ },++ "payload": {++ "name": "payload",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ }++ },++ "indexes": {++ "auto_review_projections_lead_idx": {++ "name": "auto_review_projections_lead_idx",++ "columns": [++ "lead_id"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {++ "auto_review_projections_session_id_sessions_id_fk": {++ "name": "auto_review_projections_session_id_sessions_id_fk",++ "tableFrom": "auto_review_projections",++ "tableTo": "sessions",++ "columnsFrom": [++ "session_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ },++ "auto_review_projections_lead_id_sessions_id_fk": {++ "name": "auto_review_projections_lead_id_sessions_id_fk",++ "tableFrom": "auto_review_projections",++ "tableTo": "sessions",++ "columnsFrom": [++ "lead_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {++ "auto_review_projections_session_id_lead_id_pk": {++ "columns": [++ "session_id",++ "lead_id"++ ],++ "name": "auto_review_projections_session_id_lead_id_pk"++ }++ },++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "bot_delegations": {++ "name": "bot_delegations",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "requesting_bot_id": {++ "name": "requesting_bot_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "target_bot_id": {++ "name": "target_bot_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "parent_session_id": {++ "name": "parent_session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "child_session_id": {++ "name": "child_session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "objective": {++ "name": "objective",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "context_refs_json": {++ "name": "context_refs_json",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'[]'"++ },++ "artifact_refs_json": {++ "name": "artifact_refs_json",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'[]'"++ },++ "permission_snapshot_json": {++ "name": "permission_snapshot_json",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'{}'"++ },++ "group_task_posts_json": {++ "name": "group_task_posts_json",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'{}'"++ },++ "lineage_json": {++ "name": "lineage_json",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'[]'"++ },++ "target_profile_version": {++ "name": "target_profile_version",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "depth": {++ "name": "depth",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 1++ },++ "budget_tokens": {++ "name": "budget_tokens",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "tokens_used": {++ "name": "tokens_used",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "status": {++ "name": "status",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'queued'"++ },++ "result_summary": {++ "name": "result_summary",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "output_artifacts_json": {++ "name": "output_artifacts_json",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'[]'"++ },++ "pending_interaction_json": {++ "name": "pending_interaction_json",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "last_error": {++ "name": "last_error",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "run_sequence": {++ "name": "run_sequence",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 1++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "accepted_at": {++ "name": "accepted_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "completed_at": {++ "name": "completed_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "completion_delivered_at": {++ "name": "completion_delivered_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "updated_at": {++ "name": "updated_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "idx_bot_delegations_requester_status": {++ "name": "idx_bot_delegations_requester_status",++ "columns": [++ "requesting_bot_id",++ "status"++ ],++ "isUnique": false++ },++ "idx_bot_delegations_target_status": {++ "name": "idx_bot_delegations_target_status",++ "columns": [++ "target_bot_id",++ "status"++ ],++ "isUnique": false++ },++ "idx_bot_delegations_parent_session": {++ "name": "idx_bot_delegations_parent_session",++ "columns": [++ "parent_session_id"++ ],++ "isUnique": false++ },++ "uniq_bot_delegations_child_session": {++ "name": "uniq_bot_delegations_child_session",++ "columns": [++ "child_session_id"++ ],++ "isUnique": true++ }++ },++ "foreignKeys": {++ "bot_delegations_requesting_bot_id_bot_profiles_id_fk": {++ "name": "bot_delegations_requesting_bot_id_bot_profiles_id_fk",++ "tableFrom": "bot_delegations",++ "tableTo": "bot_profiles",++ "columnsFrom": [++ "requesting_bot_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ },++ "bot_delegations_target_bot_id_bot_profiles_id_fk": {++ "name": "bot_delegations_target_bot_id_bot_profiles_id_fk",++ "tableFrom": "bot_delegations",++ "tableTo": "bot_profiles",++ "columnsFrom": [++ "target_bot_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ },++ "bot_delegations_parent_session_id_sessions_id_fk": {++ "name": "bot_delegations_parent_session_id_sessions_id_fk",++ "tableFrom": "bot_delegations",++ "tableTo": "sessions",++ "columnsFrom": [++ "parent_session_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "set null",++ "onUpdate": "no action"++ },++ "bot_delegations_child_session_id_sessions_id_fk": {++ "name": "bot_delegations_child_session_id_sessions_id_fk",++ "tableFrom": "bot_delegations",++ "tableTo": "sessions",++ "columnsFrom": [++ "child_session_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "set null",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "bot_direct_message_threads": {++ "name": "bot_direct_message_threads",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "bot_a_id": {++ "name": "bot_a_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "bot_b_id": {++ "name": "bot_b_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "status": {++ "name": "status",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'active'"++ },++ "close_reason": {++ "name": "close_reason",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "message_count": {++ "name": "message_count",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "max_messages": {++ "name": "max_messages",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "expires_at": {++ "name": "expires_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "blocked_until": {++ "name": "blocked_until",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "updated_at": {++ "name": "updated_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "closed_at": {++ "name": "closed_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ }++ },++ "indexes": {++ "uniq_bot_dm_threads_active_pair": {++ "name": "uniq_bot_dm_threads_active_pair",++ "columns": [++ "bot_a_id",++ "bot_b_id"++ ],++ "isUnique": true,++ "where": "\"bot_direct_message_threads\".\"status\" = 'active'"++ },++ "idx_bot_dm_threads_pair_updated": {++ "name": "idx_bot_dm_threads_pair_updated",++ "columns": [++ "bot_a_id",++ "bot_b_id",++ "updated_at"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "bot_direct_messages": {++ "name": "bot_direct_messages",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "thread_id": {++ "name": "thread_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "sequence": {++ "name": "sequence",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "sender_bot_id": {++ "name": "sender_bot_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "recipient_bot_id": {++ "name": "recipient_bot_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "sender_session_id": {++ "name": "sender_session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "recipient_session_id": {++ "name": "recipient_session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "delivery_status": {++ "name": "delivery_status",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'pending'"++ },++ "sender_name": {++ "name": "sender_name",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "recipient_name": {++ "name": "recipient_name",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "bridge_session_id": {++ "name": "bridge_session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "content": {++ "name": "content",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "uniq_bot_direct_messages_thread_sequence": {++ "name": "uniq_bot_direct_messages_thread_sequence",++ "columns": [++ "thread_id",++ "sequence"++ ],++ "isUnique": true++ },++ "idx_bot_direct_messages_thread_created": {++ "name": "idx_bot_direct_messages_thread_created",++ "columns": [++ "thread_id",++ "created_at"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {++ "bot_direct_messages_thread_id_bot_direct_message_threads_id_fk": {++ "name": "bot_direct_messages_thread_id_bot_direct_message_threads_id_fk",++ "tableFrom": "bot_direct_messages",++ "tableTo": "bot_direct_message_threads",++ "columnsFrom": [++ "thread_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ },++ "bot_direct_messages_sender_session_id_sessions_id_fk": {++ "name": "bot_direct_messages_sender_session_id_sessions_id_fk",++ "tableFrom": "bot_direct_messages",++ "tableTo": "sessions",++ "columnsFrom": [++ "sender_session_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "set null",++ "onUpdate": "no action"++ },++ "bot_direct_messages_recipient_session_id_sessions_id_fk": {++ "name": "bot_direct_messages_recipient_session_id_sessions_id_fk",++ "tableFrom": "bot_direct_messages",++ "tableTo": "sessions",++ "columnsFrom": [++ "recipient_session_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "set null",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "bot_group_members": {++ "name": "bot_group_members",++ "columns": {++ "group_id": {++ "name": "group_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "bot_id": {++ "name": "bot_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "position": {++ "name": "position",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "last_seen_sequence": {++ "name": "last_seen_sequence",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "joined_at": {++ "name": "joined_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "idx_bot_group_members_bot": {++ "name": "idx_bot_group_members_bot",++ "columns": [++ "bot_id"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {++ "bot_group_members_group_id_bot_groups_id_fk": {++ "name": "bot_group_members_group_id_bot_groups_id_fk",++ "tableFrom": "bot_group_members",++ "tableTo": "bot_groups",++ "columnsFrom": [++ "group_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ },++ "bot_group_members_bot_id_bot_profiles_id_fk": {++ "name": "bot_group_members_bot_id_bot_profiles_id_fk",++ "tableFrom": "bot_group_members",++ "tableTo": "bot_profiles",++ "columnsFrom": [++ "bot_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {++ "bot_group_members_group_id_bot_id_pk": {++ "columns": [++ "group_id",++ "bot_id"++ ],++ "name": "bot_group_members_group_id_bot_id_pk"++ }++ },++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "bot_group_messages": {++ "name": "bot_group_messages",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "group_id": {++ "name": "group_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "sequence": {++ "name": "sequence",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "kind": {++ "name": "kind",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'message'"++ },++ "author_kind": {++ "name": "author_kind",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "author_bot_id": {++ "name": "author_bot_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "author_name": {++ "name": "author_name",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "''"++ },++ "content": {++ "name": "content",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "''"++ },++ "mentions_json": {++ "name": "mentions_json",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'{\"all\":false,\"botIds\":[]}'"++ },++ "notice_code": {++ "name": "notice_code",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "client_id": {++ "name": "client_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "plan_id": {++ "name": "plan_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "files_json": {++ "name": "files_json",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'[]'"++ },++ "attachments_json": {++ "name": "attachments_json",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'[]'"++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "uniq_bot_group_messages_group_sequence": {++ "name": "uniq_bot_group_messages_group_sequence",++ "columns": [++ "group_id",++ "sequence"++ ],++ "isUnique": true++ },++ "uniq_bot_group_messages_group_client": {++ "name": "uniq_bot_group_messages_group_client",++ "columns": [++ "group_id",++ "client_id"++ ],++ "isUnique": true,++ "where": "\"bot_group_messages\".\"client_id\" IS NOT NULL"++ }++ },++ "foreignKeys": {++ "bot_group_messages_group_id_bot_groups_id_fk": {++ "name": "bot_group_messages_group_id_bot_groups_id_fk",++ "tableFrom": "bot_group_messages",++ "tableTo": "bot_groups",++ "columnsFrom": [++ "group_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "bot_group_plan_steps": {++ "name": "bot_group_plan_steps",++ "columns": {++ "plan_id": {++ "name": "plan_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "position": {++ "name": "position",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "bot_id": {++ "name": "bot_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "bot_name": {++ "name": "bot_name",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "task": {++ "name": "task",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "status": {++ "name": "status",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'pending'"++ },++ "result_message_id": {++ "name": "result_message_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "started_at": {++ "name": "started_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "finished_at": {++ "name": "finished_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ }++ },++ "indexes": {},++ "foreignKeys": {++ "bot_group_plan_steps_plan_id_bot_group_plans_id_fk": {++ "name": "bot_group_plan_steps_plan_id_bot_group_plans_id_fk",++ "tableFrom": "bot_group_plan_steps",++ "tableTo": "bot_group_plans",++ "columnsFrom": [++ "plan_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {++ "bot_group_plan_steps_plan_id_position_pk": {++ "columns": [++ "plan_id",++ "position"++ ],++ "name": "bot_group_plan_steps_plan_id_position_pk"++ }++ },++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "bot_group_plans": {++ "name": "bot_group_plans",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "group_id": {++ "name": "group_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "status": {++ "name": "status",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "request_text": {++ "name": "request_text",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "attachments_json": {++ "name": "attachments_json",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'[]'"++ },++ "organizer_bot_id": {++ "name": "organizer_bot_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "organizer_name": {++ "name": "organizer_name",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "current_step": {++ "name": "current_step",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "work_dir": {++ "name": "work_dir",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "branch": {++ "name": "branch",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "updated_at": {++ "name": "updated_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "idx_bot_group_plans_group_created": {++ "name": "idx_bot_group_plans_group_created",++ "columns": [++ "group_id",++ "created_at"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {++ "bot_group_plans_group_id_bot_groups_id_fk": {++ "name": "bot_group_plans_group_id_bot_groups_id_fk",++ "tableFrom": "bot_group_plans",++ "tableTo": "bot_groups",++ "columnsFrom": [++ "group_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "bot_groups": {++ "name": "bot_groups",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "name": {++ "name": "name",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "reply_mode": {++ "name": "reply_mode",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'all'"++ },++ "speaking_mode": {++ "name": "speaking_mode",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'auto'"++ },++ "organizer_bot_id": {++ "name": "organizer_bot_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "project_dir": {++ "name": "project_dir",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "updated_at": {++ "name": "updated_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "idx_bot_groups_updated": {++ "name": "idx_bot_groups_updated",++ "columns": [++ "updated_at"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "bot_lifecycle_events": {++ "name": "bot_lifecycle_events",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "bot_id": {++ "name": "bot_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "session_id": {++ "name": "session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "event_type": {++ "name": "event_type",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "payload_json": {++ "name": "payload_json",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'{}'"++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "idx_bot_lifecycle_events_bot_created": {++ "name": "idx_bot_lifecycle_events_bot_created",++ "columns": [++ "bot_id",++ "created_at"++ ],++ "isUnique": false++ },++ "idx_bot_lifecycle_events_session_created": {++ "name": "idx_bot_lifecycle_events_session_created",++ "columns": [++ "session_id",++ "created_at"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {++ "bot_lifecycle_events_bot_id_bot_profiles_id_fk": {++ "name": "bot_lifecycle_events_bot_id_bot_profiles_id_fk",++ "tableFrom": "bot_lifecycle_events",++ "tableTo": "bot_profiles",++ "columnsFrom": [++ "bot_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ },++ "bot_lifecycle_events_session_id_sessions_id_fk": {++ "name": "bot_lifecycle_events_session_id_sessions_id_fk",++ "tableFrom": "bot_lifecycle_events",++ "tableTo": "sessions",++ "columnsFrom": [++ "session_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "set null",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "bot_profile_versions": {++ "name": "bot_profile_versions",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "bot_id": {++ "name": "bot_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "version": {++ "name": "version",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "identity_source": {++ "name": "identity_source",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "''"++ },++ "capabilities_json": {++ "name": "capabilities_json",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'{}'"++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "uniq_bot_profile_versions_bot_version": {++ "name": "uniq_bot_profile_versions_bot_version",++ "columns": [++ "bot_id",++ "version"++ ],++ "isUnique": true++ },++ "idx_bot_profile_versions_bot_created": {++ "name": "idx_bot_profile_versions_bot_created",++ "columns": [++ "bot_id",++ "created_at"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {++ "bot_profile_versions_bot_id_bot_profiles_id_fk": {++ "name": "bot_profile_versions_bot_id_bot_profiles_id_fk",++ "tableFrom": "bot_profile_versions",++ "tableTo": "bot_profiles",++ "columnsFrom": [++ "bot_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "bot_profiles": {++ "name": "bot_profiles",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "display_name": {++ "name": "display_name",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "description": {++ "name": "description",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "''"++ },++ "avatar": {++ "name": "avatar",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'🤖'"++ },++ "avatar_color": {++ "name": "avatar_color",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'violet'"++ },++ "status": {++ "name": "status",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'active'"++ },++ "hidden_at": {++ "name": "hidden_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "pinned_at": {++ "name": "pinned_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "attention_reason": {++ "name": "attention_reason",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "attention_at": {++ "name": "attention_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "current_version": {++ "name": "current_version",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 1++ },++ "canonical_session_id": {++ "name": "canonical_session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "updated_at": {++ "name": "updated_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "idx_bot_profiles_status_updated": {++ "name": "idx_bot_profiles_status_updated",++ "columns": [++ "status",++ "updated_at"++ ],++ "isUnique": false++ },++ "idx_bot_profiles_canonical_session": {++ "name": "idx_bot_profiles_canonical_session",++ "columns": [++ "canonical_session_id"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {++ "bot_profiles_canonical_session_id_sessions_id_fk": {++ "name": "bot_profiles_canonical_session_id_sessions_id_fk",++ "tableFrom": "bot_profiles",++ "tableTo": "sessions",++ "columnsFrom": [++ "canonical_session_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "set null",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "bot_runtime_snapshots": {++ "name": "bot_runtime_snapshots",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "bot_id": {++ "name": "bot_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "session_id": {++ "name": "session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "profile_version": {++ "name": "profile_version",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "agent_kind": {++ "name": "agent_kind",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "working_dir": {++ "name": "working_dir",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "memory_scope_key": {++ "name": "memory_scope_key",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "configured_json": {++ "name": "configured_json",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'{}'"++ },++ "resolved_json": {++ "name": "resolved_json",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'{}'"++ },++ "status": {++ "name": "status",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "prepared_at": {++ "name": "prepared_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "applied_at": {++ "name": "applied_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "failed_at": {++ "name": "failed_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "failure_json": {++ "name": "failure_json",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ }++ },++ "indexes": {++ "idx_bot_runtime_snapshots_bot_prepared": {++ "name": "idx_bot_runtime_snapshots_bot_prepared",++ "columns": [++ "bot_id",++ "prepared_at"++ ],++ "isUnique": false++ },++ "idx_bot_runtime_snapshots_session_prepared": {++ "name": "idx_bot_runtime_snapshots_session_prepared",++ "columns": [++ "session_id",++ "prepared_at"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {++ "bot_runtime_snapshots_bot_id_bot_profiles_id_fk": {++ "name": "bot_runtime_snapshots_bot_id_bot_profiles_id_fk",++ "tableFrom": "bot_runtime_snapshots",++ "tableTo": "bot_profiles",++ "columnsFrom": [++ "bot_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ },++ "bot_runtime_snapshots_session_id_sessions_id_fk": {++ "name": "bot_runtime_snapshots_session_id_sessions_id_fk",++ "tableFrom": "bot_runtime_snapshots",++ "tableTo": "sessions",++ "columnsFrom": [++ "session_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "bot_session_links": {++ "name": "bot_session_links",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "bot_id": {++ "name": "bot_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "session_id": {++ "name": "session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "profile_version": {++ "name": "profile_version",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 1++ },++ "role": {++ "name": "role",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "route_key": {++ "name": "route_key",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "archived_at": {++ "name": "archived_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ }++ },++ "indexes": {++ "uniq_bot_session_links_session": {++ "name": "uniq_bot_session_links_session",++ "columns": [++ "session_id"++ ],++ "isUnique": true++ },++ "uniq_bot_session_links_canonical_per_bot": {++ "name": "uniq_bot_session_links_canonical_per_bot",++ "columns": [++ "bot_id"++ ],++ "isUnique": true,++ "where": "\"bot_session_links\".\"role\" = 'canonical'"++ },++ "idx_bot_session_links_bot_role": {++ "name": "idx_bot_session_links_bot_role",++ "columns": [++ "bot_id",++ "role"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {++ "bot_session_links_bot_id_bot_profiles_id_fk": {++ "name": "bot_session_links_bot_id_bot_profiles_id_fk",++ "tableFrom": "bot_session_links",++ "tableTo": "bot_profiles",++ "columnsFrom": [++ "bot_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ },++ "bot_session_links_session_id_sessions_id_fk": {++ "name": "bot_session_links_session_id_sessions_id_fk",++ "tableFrom": "bot_session_links",++ "tableTo": "sessions",++ "columnsFrom": [++ "session_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "custom_mcp_servers": {++ "name": "custom_mcp_servers",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "name": {++ "name": "name",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "transport": {++ "name": "transport",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "url": {++ "name": "url",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "headers": {++ "name": "headers",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'{}'"++ },++ "sort_order": {++ "name": "sort_order",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "updated_at": {++ "name": "updated_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "idx_custom_mcp_servers_sort_order": {++ "name": "idx_custom_mcp_servers_sort_order",++ "columns": [++ "sort_order"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "custom_providers": {++ "name": "custom_providers",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "name": {++ "name": "name",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "runtimes": {++ "name": "runtimes",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'{}'"++ },++ "auth": {++ "name": "auth",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "sort_order": {++ "name": "sort_order",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "updated_at": {++ "name": "updated_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "idx_custom_providers_sort_order": {++ "name": "idx_custom_providers_sort_order",++ "columns": [++ "sort_order"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "daily_model_usage": {++ "name": "daily_model_usage",++ "columns": {++ "day": {++ "name": "day",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "agent_kind": {++ "name": "agent_kind",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "model": {++ "name": "model",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "cost_usd": {++ "name": "cost_usd",++ "type": "real",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "cost_amount": {++ "name": "cost_amount",++ "type": "real",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "cost_currency": {++ "name": "cost_currency",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'USD'"++ },++ "cost_is_approximate": {++ "name": "cost_is_approximate",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": false++ },++ "input_tokens": {++ "name": "input_tokens",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "output_tokens": {++ "name": "output_tokens",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "cache_read_tokens": {++ "name": "cache_read_tokens",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "cache_create_tokens": {++ "name": "cache_create_tokens",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "updated_at": {++ "name": "updated_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {},++ "foreignKeys": {},++ "compositePrimaryKeys": {++ "daily_model_usage_day_agent_kind_model_cost_currency_pk": {++ "columns": [++ "day",++ "agent_kind",++ "model",++ "cost_currency"++ ],++ "name": "daily_model_usage_day_agent_kind_model_cost_currency_pk"++ }++ },++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "daily_session_usage": {++ "name": "daily_session_usage",++ "columns": {++ "day": {++ "name": "day",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "session_id": {++ "name": "session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "tokens": {++ "name": "tokens",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "updated_at": {++ "name": "updated_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {},++ "foreignKeys": {},++ "compositePrimaryKeys": {++ "daily_session_usage_day_session_id_pk": {++ "columns": [++ "day",++ "session_id"++ ],++ "name": "daily_session_usage_day_session_id_pk"++ }++ },++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "daily_spend": {++ "name": "daily_spend",++ "columns": {++ "day": {++ "name": "day",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "cost_usd": {++ "name": "cost_usd",++ "type": "real",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "cost_amount": {++ "name": "cost_amount",++ "type": "real",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "cost_currency": {++ "name": "cost_currency",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'USD'"++ },++ "cost_is_approximate": {++ "name": "cost_is_approximate",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": false++ },++ "updated_at": {++ "name": "updated_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {},++ "foreignKeys": {},++ "compositePrimaryKeys": {++ "daily_spend_day_cost_currency_pk": {++ "columns": [++ "day",++ "cost_currency"++ ],++ "name": "daily_spend_day_cost_currency_pk"++ }++ },++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "device_link_ownership": {++ "name": "device_link_ownership",++ "columns": {++ "id": {++ "name": "id",++ "type": "integer",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "owner_id": {++ "name": "owner_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "owner_pid": {++ "name": "owner_pid",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "owner_label": {++ "name": "owner_label",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "heartbeat_at": {++ "name": "heartbeat_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {},++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "embedding_jobs": {++ "name": "embedding_jobs",++ "columns": {++ "rowid": {++ "name": "rowid",++ "type": "integer",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": true++ },++ "source": {++ "name": "source",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "source_id": {++ "name": "source_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "chunk_index": {++ "name": "chunk_index",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "model_id": {++ "name": "model_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "vec_table": {++ "name": "vec_table",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "status": {++ "name": "status",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'pending'"++ },++ "attempts": {++ "name": "attempts",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "last_error": {++ "name": "last_error",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "scheduled_at": {++ "name": "scheduled_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "locked_at": {++ "name": "locked_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ }++ },++ "indexes": {++ "uniq_embedding_jobs_natural": {++ "name": "uniq_embedding_jobs_natural",++ "columns": [++ "source",++ "source_id",++ "chunk_index",++ "model_id"++ ],++ "isUnique": true++ },++ "idx_embedding_jobs_status_scheduled": {++ "name": "idx_embedding_jobs_status_scheduled",++ "columns": [++ "status",++ "scheduled_at"++ ],++ "isUnique": false++ },++ "idx_embedding_jobs_source_id": {++ "name": "idx_embedding_jobs_source_id",++ "columns": [++ "source",++ "source_id"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "embedding_meta": {++ "name": "embedding_meta",++ "columns": {++ "key": {++ "name": "key",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "value": {++ "name": "value",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ }++ },++ "indexes": {},++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "ghost_cards": {++ "name": "ghost_cards",++ "columns": {++ "call_id": {++ "name": "call_id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "ghost_id": {++ "name": "ghost_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "session_id": {++ "name": "session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "html": {++ "name": "html",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "height": {++ "name": "height",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "v": {++ "name": "v",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 1++ },++ "updated_at": {++ "name": "updated_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "ghost_cards_updated_at_idx": {++ "name": "ghost_cards_updated_at_idx",++ "columns": [++ "updated_at"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "hook_group_context_cursors": {++ "name": "hook_group_context_cursors",++ "columns": {++ "provider": {++ "name": "provider",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "cursor_key": {++ "name": "cursor_key",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "cursor_id": {++ "name": "cursor_id",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "updated_at": {++ "name": "updated_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "hook_group_context_cursors_updated_at_idx": {++ "name": "hook_group_context_cursors_updated_at_idx",++ "columns": [++ "updated_at"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {},++ "compositePrimaryKeys": {++ "hook_group_context_cursors_provider_cursor_key_pk": {++ "columns": [++ "provider",++ "cursor_key"++ ],++ "name": "hook_group_context_cursors_provider_cursor_key_pk"++ }++ },++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "hook_group_message_stats": {++ "name": "hook_group_message_stats",++ "columns": {++ "provider": {++ "name": "provider",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "row_count": {++ "name": "row_count",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "text_bytes": {++ "name": "text_bytes",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {},++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "hook_group_messages": {++ "name": "hook_group_messages",++ "columns": {++ "id": {++ "name": "id",++ "type": "integer",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": true++ },++ "provider": {++ "name": "provider",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "chat_id": {++ "name": "chat_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "thread_id": {++ "name": "thread_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "''"++ },++ "message_id": {++ "name": "message_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "chat_name": {++ "name": "chat_name",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "author": {++ "name": "author",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "is_bot": {++ "name": "is_bot",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "text": {++ "name": "text",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "file_names": {++ "name": "file_names",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "sent_at": {++ "name": "sent_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "hook_group_messages_msg_idx": {++ "name": "hook_group_messages_msg_idx",++ "columns": [++ "provider",++ "chat_id",++ "thread_id",++ "message_id"++ ],++ "isUnique": true++ },++ "hook_group_messages_window_idx": {++ "name": "hook_group_messages_window_idx",++ "columns": [++ "provider",++ "chat_id",++ "thread_id",++ "id"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "im_bindings": {++ "name": "im_bindings",++ "columns": {++ "channel": {++ "name": "channel",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "bot_context_id": {++ "name": "bot_context_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "user_id": {++ "name": "user_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "scope_key": {++ "name": "scope_key",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "''"++ },++ "target_session_id": {++ "name": "target_session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "attached_at": {++ "name": "attached_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "attached_via_card_message_id": {++ "name": "attached_via_card_message_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ }++ },++ "indexes": {++ "idx_im_bindings_target": {++ "name": "idx_im_bindings_target",++ "columns": [++ "target_session_id"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {++ "im_bindings_target_session_id_sessions_id_fk": {++ "name": "im_bindings_target_session_id_sessions_id_fk",++ "tableFrom": "im_bindings",++ "tableTo": "sessions",++ "columnsFrom": [++ "target_session_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {++ "im_bindings_channel_bot_context_id_user_id_scope_key_pk": {++ "columns": [++ "channel",++ "bot_context_id",++ "user_id",++ "scope_key"++ ],++ "name": "im_bindings_channel_bot_context_id_user_id_scope_key_pk"++ }++ },++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "im_notification_origins": {++ "name": "im_notification_origins",++ "columns": {++ "channel": {++ "name": "channel",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "bot_context_id": {++ "name": "bot_context_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "user_id": {++ "name": "user_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "message_id": {++ "name": "message_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "chat_id": {++ "name": "chat_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "session_id": {++ "name": "session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {},++ "foreignKeys": {},++ "compositePrimaryKeys": {++ "im_notification_origins_channel_bot_context_id_user_id_message_id_pk": {++ "columns": [++ "channel",++ "bot_context_id",++ "user_id",++ "message_id"++ ],++ "name": "im_notification_origins_channel_bot_context_id_user_id_message_id_pk"++ }++ },++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "media_blobs": {++ "name": "media_blobs",++ "columns": {++ "hash": {++ "name": "hash",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "ext": {++ "name": "ext",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "mime_type": {++ "name": "mime_type",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "bytes": {++ "name": "bytes",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "is_cache": {++ "name": "is_cache",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": false++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "last_access_at": {++ "name": "last_access_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {},++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "media_invocations": {++ "name": "media_invocations",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "owner": {++ "name": "owner",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "model_id": {++ "name": "model_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "capability": {++ "name": "capability",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "guide_revision": {++ "name": "guide_revision",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "guide_json": {++ "name": "guide_json",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "state": {++ "name": "state",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "task_id": {++ "name": "task_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "response_json": {++ "name": "response_json",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "updated_at": {++ "name": "updated_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "media_invocations_owner_created_at_idx": {++ "name": "media_invocations_owner_created_at_idx",++ "columns": [++ "owner",++ "created_at"++ ],++ "isUnique": false++ },++ "media_invocations_owner_state_idx": {++ "name": "media_invocations_owner_state_idx",++ "columns": [++ "owner",++ "state"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "media_refs": {++ "name": "media_refs",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "hash": {++ "name": "hash",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "ref_kind": {++ "name": "ref_kind",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "ref_id": {++ "name": "ref_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "origin_session_id": {++ "name": "origin_session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "origin_kind": {++ "name": "origin_kind",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "origin_id": {++ "name": "origin_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "label": {++ "name": "label",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "media_refs_hash_idx": {++ "name": "media_refs_hash_idx",++ "columns": [++ "hash"++ ],++ "isUnique": false++ },++ "media_refs_ref_idx": {++ "name": "media_refs_ref_idx",++ "columns": [++ "ref_kind",++ "ref_id"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {++ "media_refs_hash_media_blobs_hash_fk": {++ "name": "media_refs_hash_media_blobs_hash_fk",++ "tableFrom": "media_refs",++ "tableTo": "media_blobs",++ "columnsFrom": [++ "hash"++ ],++ "columnsTo": [++ "hash"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "messages": {++ "name": "messages",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "client_id": {++ "name": "client_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "session_id": {++ "name": "session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "role": {++ "name": "role",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "content": {++ "name": "content",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "tool_use_id": {++ "name": "tool_use_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "agent_meta": {++ "name": "agent_meta",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "agent_kind": {++ "name": "agent_kind",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "rewind_at": {++ "name": "rewind_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ }++ },++ "indexes": {++ "uniq_messages_session_client": {++ "name": "uniq_messages_session_client",++ "columns": [++ "session_id",++ "client_id"++ ],++ "isUnique": true++ },++ "idx_messages_session_created": {++ "name": "idx_messages_session_created",++ "columns": [++ "session_id",++ "created_at"++ ],++ "isUnique": false++ },++ "idx_messages_created_at": {++ "name": "idx_messages_created_at",++ "columns": [++ "created_at",++ "id"++ ],++ "isUnique": false++ },++ "idx_messages_rewind_at": {++ "name": "idx_messages_rewind_at",++ "columns": [++ "rewind_at"++ ],++ "isUnique": false++ },++ "idx_messages_active_error_tail": {++ "name": "idx_messages_active_error_tail",++ "columns": [++ "session_id",++ "created_at"++ ],++ "isUnique": false,++ "where": "\"messages\".\"role\" = 'error' AND \"messages\".\"rewind_at\" IS NULL"++ }++ },++ "foreignKeys": {++ "messages_session_id_sessions_id_fk": {++ "name": "messages_session_id_sessions_id_fk",++ "tableFrom": "messages",++ "tableTo": "sessions",++ "columnsFrom": [++ "session_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "messages_fts_rows": {++ "name": "messages_fts_rows",++ "columns": {++ "fts_rowid": {++ "name": "fts_rowid",++ "type": "integer",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": true++ },++ "message_id": {++ "name": "message_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "messages_fts_rows_message_id_idx": {++ "name": "messages_fts_rows_message_id_idx",++ "columns": [++ "message_id"++ ],++ "isUnique": true++ }++ },++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "migration_history": {++ "name": "migration_history",++ "columns": {++ "seq": {++ "name": "seq",++ "type": "integer",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "file_name": {++ "name": "file_name",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "content_hash": {++ "name": "content_hash",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "applied_at": {++ "name": "applied_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {},++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "migration_meta": {++ "name": "migration_meta",++ "columns": {++ "key": {++ "name": "key",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "value": {++ "name": "value",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ }++ },++ "indexes": {},++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "orca_remote_opens": {++ "name": "orca_remote_opens",++ "columns": {++ "remote_session_id": {++ "name": "remote_session_id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "device_id": {++ "name": "device_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {},++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "orca_teams": {++ "name": "orca_teams",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "lead_session_id": {++ "name": "lead_session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "status": {++ "name": "status",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'active'"++ },++ "completed_at": {++ "name": "completed_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "updated_at": {++ "name": "updated_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "uniq_active_team_per_lead": {++ "name": "uniq_active_team_per_lead",++ "columns": [++ "lead_session_id"++ ],++ "isUnique": true,++ "where": "\"orca_teams\".\"status\" = 'active'"++ },++ "idx_orca_teams_status": {++ "name": "idx_orca_teams_status",++ "columns": [++ "status"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {++ "orca_teams_lead_session_id_sessions_id_fk": {++ "name": "orca_teams_lead_session_id_sessions_id_fk",++ "tableFrom": "orca_teams",++ "tableTo": "sessions",++ "columnsFrom": [++ "lead_session_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "orca_worker_creation_reservations": {++ "name": "orca_worker_creation_reservations",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "team_id": {++ "name": "team_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "label": {++ "name": "label",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "expires_at": {++ "name": "expires_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "uniq_orca_worker_creation_reservations_team_label": {++ "name": "uniq_orca_worker_creation_reservations_team_label",++ "columns": [++ "team_id",++ "lower(\"label\")"++ ],++ "isUnique": true++ },++ "idx_orca_worker_creation_reservations_expires_at": {++ "name": "idx_orca_worker_creation_reservations_expires_at",++ "columns": [++ "expires_at"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {++ "orca_worker_creation_reservations_team_id_orca_teams_id_fk": {++ "name": "orca_worker_creation_reservations_team_id_orca_teams_id_fk",++ "tableFrom": "orca_worker_creation_reservations",++ "tableTo": "orca_teams",++ "columnsFrom": [++ "team_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "orca_workers": {++ "name": "orca_workers",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "team_id": {++ "name": "team_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "session_id": {++ "name": "session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "status": {++ "name": "status",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'idle'"++ },++ "label": {++ "name": "label",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "worktree_branch": {++ "name": "worktree_branch",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "role": {++ "name": "role",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'developer'"++ },++ "focused": {++ "name": "focused",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": false++ },++ "idle_since": {++ "name": "idle_since",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "execution_device_id": {++ "name": "execution_device_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "remote_session_id": {++ "name": "remote_session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "last_bridged_message_id": {++ "name": "last_bridged_message_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "remote_released_at": {++ "name": "remote_released_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "pending_remote_report": {++ "name": "pending_remote_report",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "remote_stop_confirmed_at": {++ "name": "remote_stop_confirmed_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "updated_at": {++ "name": "updated_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "uniq_orca_workers_session_id": {++ "name": "uniq_orca_workers_session_id",++ "columns": [++ "session_id"++ ],++ "isUnique": true++ },++ "uniq_orca_workers_team_label": {++ "name": "uniq_orca_workers_team_label",++ "columns": [++ "team_id",++ "lower(\"label\")"++ ],++ "isUnique": true++ },++ "uniq_orca_workers_focused_per_team": {++ "name": "uniq_orca_workers_focused_per_team",++ "columns": [++ "team_id"++ ],++ "isUnique": true,++ "where": "\"orca_workers\".\"focused\" = true"++ },++ "idx_orca_workers_team_id": {++ "name": "idx_orca_workers_team_id",++ "columns": [++ "team_id"++ ],++ "isUnique": false++ },++ "idx_orca_workers_status": {++ "name": "idx_orca_workers_status",++ "columns": [++ "status"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {++ "orca_workers_team_id_orca_teams_id_fk": {++ "name": "orca_workers_team_id_orca_teams_id_fk",++ "tableFrom": "orca_workers",++ "tableTo": "orca_teams",++ "columnsFrom": [++ "team_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ },++ "orca_workers_session_id_sessions_id_fk": {++ "name": "orca_workers_session_id_sessions_id_fk",++ "tableFrom": "orca_workers",++ "tableTo": "sessions",++ "columnsFrom": [++ "session_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "plugin_task_requests": {++ "name": "plugin_task_requests",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "plugin_id": {++ "name": "plugin_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "operation": {++ "name": "operation",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "target_id": {++ "name": "target_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "request_key": {++ "name": "request_key",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "fingerprint": {++ "name": "fingerprint",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "payload": {++ "name": "payload",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "revision": {++ "name": "revision",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "plugin_task_request_key": {++ "name": "plugin_task_request_key",++ "columns": [++ "plugin_id",++ "operation",++ "target_id",++ "request_key"++ ],++ "isUnique": true++ },++ "plugin_task_target": {++ "name": "plugin_task_target",++ "columns": [++ "target_id",++ "plugin_id"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "plugin_usage_events": {++ "name": "plugin_usage_events",++ "columns": {++ "call_id": {++ "name": "call_id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "subject_id": {++ "name": "subject_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "history_generation": {++ "name": "history_generation",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "occurred_at": {++ "name": "occurred_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "tool_name": {++ "name": "tool_name",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "session_id": {++ "name": "session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "version": {++ "name": "version",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "release_id": {++ "name": "release_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "outcome": {++ "name": "outcome",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'unknown'"++ },++ "report_target": {++ "name": "report_target",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "report_state": {++ "name": "report_state",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'not-applicable'"++ },++ "next_attempt_at": {++ "name": "next_attempt_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "attempt_count": {++ "name": "attempt_count",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ }++ },++ "indexes": {++ "plugin_usage_events_time_idx": {++ "name": "plugin_usage_events_time_idx",++ "columns": [++ "subject_id",++ "occurred_at"++ ],++ "isUnique": false++ },++ "plugin_usage_events_task_idx": {++ "name": "plugin_usage_events_task_idx",++ "columns": [++ "subject_id",++ "session_id",++ "occurred_at"++ ],++ "isUnique": false++ },++ "plugin_usage_events_pending_idx": {++ "name": "plugin_usage_events_pending_idx",++ "columns": [++ "next_attempt_at",++ "occurred_at"++ ],++ "isUnique": false,++ "where": "\"plugin_usage_events\".\"report_state\" = 'pending'"++ }++ },++ "foreignKeys": {++ "plugin_usage_events_subject_id_plugin_usage_subjects_id_fk": {++ "name": "plugin_usage_events_subject_id_plugin_usage_subjects_id_fk",++ "tableFrom": "plugin_usage_events",++ "tableTo": "plugin_usage_subjects",++ "columnsFrom": [++ "subject_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "no action",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "plugin_usage_subjects": {++ "name": "plugin_usage_subjects",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "stable_key": {++ "name": "stable_key",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "source_kind": {++ "name": "source_kind",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "plugin_id": {++ "name": "plugin_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "organization_id": {++ "name": "organization_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "source_key": {++ "name": "source_key",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "server_root": {++ "name": "server_root",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "ghost_id": {++ "name": "ghost_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "display_name": {++ "name": "display_name",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "binding_revision": {++ "name": "binding_revision",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "recording_started_at": {++ "name": "recording_started_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "history_generation": {++ "name": "history_generation",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ }++ },++ "indexes": {++ "plugin_usage_subjects_source_idx": {++ "name": "plugin_usage_subjects_source_idx",++ "columns": [++ "stable_key"++ ],++ "isUnique": true++ },++ "plugin_usage_subjects_binding_idx": {++ "name": "plugin_usage_subjects_binding_idx",++ "columns": [++ "ghost_id",++ "binding_revision"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "project_aliases": {++ "name": "project_aliases",++ "columns": {++ "project_key": {++ "name": "project_key",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "alias": {++ "name": "alias",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "updated_at": {++ "name": "updated_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "idx_project_aliases_updated_at": {++ "name": "idx_project_aliases_updated_at",++ "columns": [++ "updated_at"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "project_automation_consents": {++ "name": "project_automation_consents",++ "columns": {++ "working_dir": {++ "name": "working_dir",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "consented_at": {++ "name": "consented_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "config_hash": {++ "name": "config_hash",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {},++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "recent_workdirs": {++ "name": "recent_workdirs",++ "columns": {++ "path": {++ "name": "path",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "last_used_at": {++ "name": "last_used_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "idx_recent_workdirs_last_used_at": {++ "name": "idx_recent_workdirs_last_used_at",++ "columns": [++ "last_used_at"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "right_sidebar_tabs": {++ "name": "right_sidebar_tabs",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "session_id": {++ "name": "session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "kind": {++ "name": "kind",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "position": {++ "name": "position",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "is_active": {++ "name": "is_active",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": false++ },++ "state": {++ "name": "state",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'{}'"++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "updated_at": {++ "name": "updated_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "right_sidebar_tabs_session_idx": {++ "name": "right_sidebar_tabs_session_idx",++ "columns": [++ "session_id",++ "position"++ ],++ "isUnique": false++ },++ "right_sidebar_tabs_subagents_singleton_idx": {++ "name": "right_sidebar_tabs_subagents_singleton_idx",++ "columns": [++ "session_id"++ ],++ "isUnique": true,++ "where": "\"right_sidebar_tabs\".\"kind\" = 'subagents'"++ },++ "right_sidebar_tabs_bot_artifacts_singleton_idx": {++ "name": "right_sidebar_tabs_bot_artifacts_singleton_idx",++ "columns": [++ "session_id"++ ],++ "isUnique": true,++ "where": "\"right_sidebar_tabs\".\"kind\" = 'bot-artifacts'"++ }++ },++ "foreignKeys": {++ "right_sidebar_tabs_session_id_sessions_id_fk": {++ "name": "right_sidebar_tabs_session_id_sessions_id_fk",++ "tableFrom": "right_sidebar_tabs",++ "tableTo": "sessions",++ "columnsFrom": [++ "session_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "schedule_runs": {++ "name": "schedule_runs",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "schedule_id": {++ "name": "schedule_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "session_id": {++ "name": "session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "fired_at": {++ "name": "fired_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "finished_at": {++ "name": "finished_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "status": {++ "name": "status",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "error_msg": {++ "name": "error_msg",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "cost_usd": {++ "name": "cost_usd",++ "type": "real",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "estimated_value_usd": {++ "name": "estimated_value_usd",++ "type": "real",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "cost_amount": {++ "name": "cost_amount",++ "type": "real",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "estimated_value_amount": {++ "name": "estimated_value_amount",++ "type": "real",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "cost_currency": {++ "name": "cost_currency",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "cost_is_approximate": {++ "name": "cost_is_approximate",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": false++ },++ "cost_attribution": {++ "name": "cost_attribution",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'legacy'"++ },++ "result_text": {++ "name": "result_text",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "pre_run_hook_result": {++ "name": "pre_run_hook_result",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "read_at": {++ "name": "read_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "heartbeat_at": {++ "name": "heartbeat_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ }++ },++ "indexes": {++ "idx_schedule_runs_schedule": {++ "name": "idx_schedule_runs_schedule",++ "columns": [++ "schedule_id",++ "fired_at"++ ],++ "isUnique": false++ },++ "idx_schedule_runs_running_schedule": {++ "name": "idx_schedule_runs_running_schedule",++ "columns": [++ "schedule_id"++ ],++ "isUnique": false,++ "where": "\"schedule_runs\".\"status\" = 'running'"++ },++ "idx_schedule_runs_running_heartbeat": {++ "name": "idx_schedule_runs_running_heartbeat",++ "columns": [++ "heartbeat_at"++ ],++ "isUnique": false,++ "where": "\"schedule_runs\".\"status\" = 'running' AND \"schedule_runs\".\"heartbeat_at\" IS NOT NULL"++ },++ "idx_schedule_runs_running_legacy": {++ "name": "idx_schedule_runs_running_legacy",++ "columns": [++ "fired_at"++ ],++ "isUnique": false,++ "where": "\"schedule_runs\".\"status\" = 'running' AND \"schedule_runs\".\"heartbeat_at\" IS NULL"++ },++ "idx_schedule_runs_unread_terminal": {++ "name": "idx_schedule_runs_unread_terminal",++ "columns": [++ "schedule_id",++ "status",++ "fired_at"++ ],++ "isUnique": false,++ "where": "\"schedule_runs\".\"read_at\" IS NULL AND \"schedule_runs\".\"status\" IN ('success', 'failed', 'aborted', 'interrupted')"++ },++ "idx_schedule_runs_session_latest": {++ "name": "idx_schedule_runs_session_latest",++ "columns": [++ "session_id",++ "fired_at",++ "id"++ ],++ "isUnique": false,++ "where": "\"schedule_runs\".\"session_id\" IS NOT NULL"++ }++ },++ "foreignKeys": {++ "schedule_runs_schedule_id_schedules_id_fk": {++ "name": "schedule_runs_schedule_id_schedules_id_fk",++ "tableFrom": "schedule_runs",++ "tableTo": "schedules",++ "columnsFrom": [++ "schedule_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ },++ "schedule_runs_session_id_sessions_id_fk": {++ "name": "schedule_runs_session_id_sessions_id_fk",++ "tableFrom": "schedule_runs",++ "tableTo": "sessions",++ "columnsFrom": [++ "session_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "set null",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "schedule_session_latest_runs": {++ "name": "schedule_session_latest_runs",++ "columns": {++ "session_id": {++ "name": "session_id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "run_id": {++ "name": "run_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "fired_at": {++ "name": "fired_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "idx_schedule_session_latest_runs_run": {++ "name": "idx_schedule_session_latest_runs_run",++ "columns": [++ "run_id"++ ],++ "isUnique": true++ }++ },++ "foreignKeys": {++ "schedule_session_latest_runs_session_id_sessions_id_fk": {++ "name": "schedule_session_latest_runs_session_id_sessions_id_fk",++ "tableFrom": "schedule_session_latest_runs",++ "tableTo": "sessions",++ "columnsFrom": [++ "session_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ },++ "schedule_session_latest_runs_run_id_schedule_runs_id_fk": {++ "name": "schedule_session_latest_runs_run_id_schedule_runs_id_fk",++ "tableFrom": "schedule_session_latest_runs",++ "tableTo": "schedule_runs",++ "columnsFrom": [++ "run_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "schedules": {++ "name": "schedules",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "name": {++ "name": "name",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "prompt": {++ "name": "prompt",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "job_type": {++ "name": "job_type",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'prompt'"++ },++ "job_config": {++ "name": "job_config",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "execution_mode": {++ "name": "execution_mode",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'agent'"++ },++ "script_config": {++ "name": "script_config",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "source": {++ "name": "source",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false,++ "default": "'user'"++ },++ "project_config_id": {++ "name": "project_config_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "legacy_session_fallback": {++ "name": "legacy_session_fallback",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": false++ },++ "kind": {++ "name": "kind",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'cron'"++ },++ "cron_expr": {++ "name": "cron_expr",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "timezone": {++ "name": "timezone",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "recurring": {++ "name": "recurring",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": true++ },++ "manual": {++ "name": "manual",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": false++ },++ "interval_ms": {++ "name": "interval_ms",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "agent_kind": {++ "name": "agent_kind",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "model_agent_kind": {++ "name": "model_agent_kind",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "model": {++ "name": "model",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "provider_id": {++ "name": "provider_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "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++ },++ "hidden_at": {++ "name": "hidden_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "summary": {++ "name": "summary",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "provider_id": {++ "name": "provider_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "user_send_at": {++ "name": "user_send_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "agent_kind": {++ "name": "agent_kind",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'cc'"++ },++ "orca_role": {++ "name": "orca_role",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "parent_session_id": {++ "name": "parent_session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "forked_at_message_id": {++ "name": "forked_at_message_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "worktree_path": {++ "name": "worktree_path",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "source": {++ "name": "source",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'desktop'"++ },++ "feishu_open_id": {++ "name": "feishu_open_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "feishu_bot_app_id": {++ "name": "feishu_bot_app_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "im_bot_context_id": {++ "name": "im_bot_context_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "im_user_id": {++ "name": "im_user_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "im_default_route": {++ "name": "im_default_route",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "used_project_context": {++ "name": "used_project_context",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": false++ },++ "codex_history_has_product_prompt": {++ "name": "codex_history_has_product_prompt",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "codex_plan_json": {++ "name": "codex_plan_json",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "extra_dirs": {++ "name": "extra_dirs",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'[]'"++ },++ "writable_dirs": {++ "name": "writable_dirs",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'[]'"++ },++ "remote_host_id": {++ "name": "remote_host_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "agent_device_id": {++ "name": "agent_device_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "orca_remote_lead": {++ "name": "orca_remote_lead",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "active_turn_started_at": {++ "name": "active_turn_started_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "active_turn_pid": {++ "name": "active_turn_pid",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "last_turn_ended_at": {++ "name": "last_turn_ended_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "list_preview": {++ "name": "list_preview",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "list_preview_role": {++ "name": "list_preview_role",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "list_message_count": {++ "name": "list_message_count",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "updated_at": {++ "name": "updated_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "idx_sessions_updated_at": {++ "name": "idx_sessions_updated_at",++ "columns": [++ "updated_at"++ ],++ "isUnique": false++ },++ "idx_sessions_user_send_at": {++ "name": "idx_sessions_user_send_at",++ "columns": [++ "user_send_at"++ ],++ "isUnique": false++ },++ "idx_sessions_sdk_session_id": {++ "name": "idx_sessions_sdk_session_id",++ "columns": [++ "sdk_session_id"++ ],++ "isUnique": false++ },++ "idx_sessions_workdir_created": {++ "name": "idx_sessions_workdir_created",++ "columns": [++ "working_dir",++ "created_at",++ "id"++ ],++ "isUnique": false++ },++ "idx_sessions_created_at": {++ "name": "idx_sessions_created_at",++ "columns": [++ "created_at",++ "id"++ ],++ "isUnique": false++ },++ "idx_sessions_workspace_kind": {++ "name": "idx_sessions_workspace_kind",++ "columns": [++ "workspace_kind"++ ],++ "isUnique": false++ },++ "idx_sessions_parent_session_id": {++ "name": "idx_sessions_parent_session_id",++ "columns": [++ "parent_session_id"++ ],++ "isUnique": false++ },++ "idx_sessions_orca_role": {++ "name": "idx_sessions_orca_role",++ "columns": [++ "orca_role"++ ],++ "isUnique": false++ },++ "idx_sessions_worktree_path": {++ "name": "idx_sessions_worktree_path",++ "columns": [++ "worktree_path"++ ],++ "isUnique": false++ },++ "idx_sessions_feishu_lookup": {++ "name": "idx_sessions_feishu_lookup",++ "columns": [++ "source",++ "feishu_bot_app_id",++ "feishu_open_id"++ ],++ "isUnique": false++ },++ "idx_sessions_im_lookup": {++ "name": "idx_sessions_im_lookup",++ "columns": [++ "source",++ "im_bot_context_id",++ "im_user_id"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {++ "sessions_parent_session_id_sessions_id_fk": {++ "name": "sessions_parent_session_id_sessions_id_fk",++ "tableFrom": "sessions",++ "tableTo": "sessions",++ "columnsFrom": [++ "parent_session_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "set null",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "shared_task_events": {++ "name": "shared_task_events",++ "columns": {++ "id": {++ "name": "id",++ "type": "integer",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": true++ },++ "shared_task_id": {++ "name": "shared_task_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "session_id": {++ "name": "session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "revision": {++ "name": "revision",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "kind": {++ "name": "kind",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "terminal": {++ "name": "terminal",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "snapshot": {++ "name": "snapshot",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "recorded_at": {++ "name": "recorded_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "shared_task_events_revision_idx": {++ "name": "shared_task_events_revision_idx",++ "columns": [++ "shared_task_id",++ "kind",++ "revision"++ ],++ "isUnique": true++ },++ "shared_task_events_session_idx": {++ "name": "shared_task_events_session_idx",++ "columns": [++ "session_id",++ "id"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {++ "shared_task_events_session_id_sessions_id_fk": {++ "name": "shared_task_events_session_id_sessions_id_fk",++ "tableFrom": "shared_task_events",++ "tableTo": "sessions",++ "columnsFrom": [++ "session_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "skill_usage_exposures": {++ "name": "skill_usage_exposures",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "analyzer_version": {++ "name": "analyzer_version",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'6'"++ },++ "raw_file_path": {++ "name": "raw_file_path",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "raw_line_no": {++ "name": "raw_line_no",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "session_id": {++ "name": "session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "sdk_session_id": {++ "name": "sdk_session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "agent_kind": {++ "name": "agent_kind",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "skill_name": {++ "name": "skill_name",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "skill_path": {++ "name": "skill_path",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "skill_document_hash": {++ "name": "skill_document_hash",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "exposure_content_hash": {++ "name": "exposure_content_hash",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "document_hash_source": {++ "name": "document_hash_source",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "source": {++ "name": "source",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "tool_use_id": {++ "name": "tool_use_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "seen_at": {++ "name": "seen_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "tool_call_count": {++ "name": "tool_call_count",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "repeated_tool_call_count": {++ "name": "repeated_tool_call_count",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "tool_error_count": {++ "name": "tool_error_count",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "command_call_count": {++ "name": "command_call_count",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "command_failure_count": {++ "name": "command_failure_count",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ }++ },++ "indexes": {++ "idx_skill_usage_exposures_skill_document_version": {++ "name": "idx_skill_usage_exposures_skill_document_version",++ "columns": [++ "analyzer_version",++ "skill_name",++ "skill_document_hash"++ ],++ "isUnique": false++ },++ "idx_skill_usage_exposures_skill_recent": {++ "name": "idx_skill_usage_exposures_skill_recent",++ "columns": [++ "skill_name",++ "analyzer_version",++ "seen_at"++ ],++ "isUnique": false++ },++ "idx_skill_usage_exposures_skill_recent_any_version": {++ "name": "idx_skill_usage_exposures_skill_recent_any_version",++ "columns": [++ "skill_name",++ "seen_at"++ ],++ "isUnique": false++ },++ "idx_skill_usage_exposures_analyzer_recent_source": {++ "name": "idx_skill_usage_exposures_analyzer_recent_source",++ "columns": [++ "analyzer_version",++ "seen_at",++ "raw_file_path"++ ],++ "isUnique": false++ },++ "idx_skill_usage_exposures_session": {++ "name": "idx_skill_usage_exposures_session",++ "columns": [++ "session_id"++ ],++ "isUnique": false++ },++ "idx_skill_usage_exposures_raw_file": {++ "name": "idx_skill_usage_exposures_raw_file",++ "columns": [++ "raw_file_path"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {++ "skill_usage_exposures_raw_file_path_skill_usage_sources_raw_file_path_fk": {++ "name": "skill_usage_exposures_raw_file_path_skill_usage_sources_raw_file_path_fk",++ "tableFrom": "skill_usage_exposures",++ "tableTo": "skill_usage_sources",++ "columnsFrom": [++ "raw_file_path"++ ],++ "columnsTo": [++ "raw_file_path"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "skill_usage_sources": {++ "name": "skill_usage_sources",++ "columns": {++ "raw_file_path": {++ "name": "raw_file_path",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "analyzer_version": {++ "name": "analyzer_version",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'6'"++ },++ "agent_kind": {++ "name": "agent_kind",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "session_id": {++ "name": "session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "sdk_session_id": {++ "name": "sdk_session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "mtime_ms": {++ "name": "mtime_ms",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "size_bytes": {++ "name": "size_bytes",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "last_scanned_at": {++ "name": "last_scanned_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "status": {++ "name": "status",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'ok'"++ },++ "error": {++ "name": "error",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ }++ },++ "indexes": {++ "idx_skill_usage_sources_session": {++ "name": "idx_skill_usage_sources_session",++ "columns": [++ "session_id"++ ],++ "isUnique": false++ },++ "idx_skill_usage_sources_sdk_session": {++ "name": "idx_skill_usage_sources_sdk_session",++ "columns": [++ "sdk_session_id"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "subagent_run_aliases": {++ "name": "subagent_run_aliases",++ "columns": {++ "session_id": {++ "name": "session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "provider": {++ "name": "provider",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "alias": {++ "name": "alias",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "run_id": {++ "name": "run_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "subagent_run_aliases_lookup_idx": {++ "name": "subagent_run_aliases_lookup_idx",++ "columns": [++ "session_id",++ "provider",++ "alias",++ "created_at"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {++ "subagent_run_aliases_session_id_sessions_id_fk": {++ "name": "subagent_run_aliases_session_id_sessions_id_fk",++ "tableFrom": "subagent_run_aliases",++ "tableTo": "sessions",++ "columnsFrom": [++ "session_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ },++ "subagent_run_aliases_run_id_subagent_runs_id_fk": {++ "name": "subagent_run_aliases_run_id_subagent_runs_id_fk",++ "tableFrom": "subagent_run_aliases",++ "tableTo": "subagent_runs",++ "columnsFrom": [++ "run_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {++ "subagent_run_aliases_run_id_alias_pk": {++ "columns": [++ "run_id",++ "alias"++ ],++ "name": "subagent_run_aliases_run_id_alias_pk"++ }++ },++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "subagent_runs": {++ "name": "subagent_runs",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "session_id": {++ "name": "session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "provider": {++ "name": "provider",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "logical_agent_id": {++ "name": "logical_agent_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "parent_tool_use_id": {++ "name": "parent_tool_use_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "aliases": {++ "name": "aliases",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'[]'"++ },++ "provider_run_ids": {++ "name": "provider_run_ids",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'[]'"++ },++ "status": {++ "name": "status",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'running'"++ },++ "title": {++ "name": "title",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "description": {++ "name": "description",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "summary": {++ "name": "summary",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "returned_result": {++ "name": "returned_result",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "returned_result_empty": {++ "name": "returned_result_empty",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "returned_result_truncated": {++ "name": "returned_result_truncated",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "model": {++ "name": "model",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "reasoning_effort": {++ "name": "reasoning_effort",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "total_tokens": {++ "name": "total_tokens",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "tool_uses": {++ "name": "tool_uses",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "duration_ms": {++ "name": "duration_ms",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "cost_usd": {++ "name": "cost_usd",++ "type": "real",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "capabilities": {++ "name": "capabilities",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'{}'"++ },++ "activity": {++ "name": "activity",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'[]'"++ },++ "started_at": {++ "name": "started_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "updated_at": {++ "name": "updated_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "ended_at": {++ "name": "ended_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "rewind_at": {++ "name": "rewind_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "deleted_at": {++ "name": "deleted_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ }++ },++ "indexes": {++ "subagent_runs_logical_idx": {++ "name": "subagent_runs_logical_idx",++ "columns": [++ "session_id",++ "provider",++ "logical_agent_id"++ ],++ "isUnique": false++ },++ "subagent_runs_session_idx": {++ "name": "subagent_runs_session_idx",++ "columns": [++ "session_id",++ "rewind_at",++ "deleted_at",++ "started_at"++ ],++ "isUnique": false++ },++ "subagent_runs_parent_tool_use_idx": {++ "name": "subagent_runs_parent_tool_use_idx",++ "columns": [++ "session_id",++ "parent_tool_use_id"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {++ "subagent_runs_session_id_sessions_id_fk": {++ "name": "subagent_runs_session_id_sessions_id_fk",++ "tableFrom": "subagent_runs",++ "tableTo": "sessions",++ "columnsFrom": [++ "session_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "task_tags": {++ "name": "task_tags",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "name": {++ "name": "name",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "name_customized": {++ "name": "name_customized",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": false++ },++ "color": {++ "name": "color",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "favorite_order": {++ "name": "favorite_order",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "sort_order": {++ "name": "sort_order",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "revision": {++ "name": "revision",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 1++ }++ },++ "indexes": {++ "task_tags_name_idx": {++ "name": "task_tags_name_idx",++ "columns": [++ "name"++ ],++ "isUnique": true++ }++ },++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "vec_table_meta": {++ "name": "vec_table_meta",++ "columns": {++ "vec_table": {++ "name": "vec_table",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "source": {++ "name": "source",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "model_id": {++ "name": "model_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "dim": {++ "name": "dim",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "registered_at": {++ "name": "registered_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "notes": {++ "name": "notes",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ }++ },++ "indexes": {},++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "wechat_file_attachments": {++ "name": "wechat_file_attachments",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "binding_epoch": {++ "name": "binding_epoch",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "task_id": {++ "name": "task_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "session_id": {++ "name": "session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "abs_path": {++ "name": "abs_path",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "original_name": {++ "name": "original_name",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "mime_type": {++ "name": "mime_type",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "bytes": {++ "name": "bytes",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "status": {++ "name": "status",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'staged'"++ },++ "promoted_at": {++ "name": "promoted_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "idx_wechat_file_attachments_task": {++ "name": "idx_wechat_file_attachments_task",++ "columns": [++ "binding_epoch",++ "task_id"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {++ "wechat_file_attachments_binding_epoch_wechat_sync_state_binding_epoch_fk": {++ "name": "wechat_file_attachments_binding_epoch_wechat_sync_state_binding_epoch_fk",++ "tableFrom": "wechat_file_attachments",++ "tableTo": "wechat_sync_state",++ "columnsFrom": [++ "binding_epoch"++ ],++ "columnsTo": [++ "binding_epoch"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ },++ "wechat_file_attachments_task_id_wechat_inbox_id_fk": {++ "name": "wechat_file_attachments_task_id_wechat_inbox_id_fk",++ "tableFrom": "wechat_file_attachments",++ "tableTo": "wechat_inbox",++ "columnsFrom": [++ "task_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ },++ "wechat_file_attachments_session_id_sessions_id_fk": {++ "name": "wechat_file_attachments_session_id_sessions_id_fk",++ "tableFrom": "wechat_file_attachments",++ "tableTo": "sessions",++ "columnsFrom": [++ "session_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "set null",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "wechat_inbox": {++ "name": "wechat_inbox",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "binding_epoch": {++ "name": "binding_epoch",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "platform_message_id": {++ "name": "platform_message_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "platform_seq": {++ "name": "platform_seq",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "peer_id": {++ "name": "peer_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "received_at": {++ "name": "received_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "platform_created_at": {++ "name": "platform_created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "expires_at": {++ "name": "expires_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "status": {++ "name": "status",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'pending'"++ },++ "lease_until": {++ "name": "lease_until",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "session_id": {++ "name": "session_id",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "conversation_epoch": {++ "name": "conversation_epoch",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "payload_json": {++ "name": "payload_json",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "context_nonce": {++ "name": "context_nonce",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "context_ciphertext": {++ "name": "context_ciphertext",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "context_tag": {++ "name": "context_tag",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "attempts": {++ "name": "attempts",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "last_error_code": {++ "name": "last_error_code",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ }++ },++ "indexes": {++ "uniq_wechat_inbox_platform_message": {++ "name": "uniq_wechat_inbox_platform_message",++ "columns": [++ "binding_epoch",++ "platform_message_id"++ ],++ "isUnique": true++ },++ "idx_wechat_inbox_queue": {++ "name": "idx_wechat_inbox_queue",++ "columns": [++ "binding_epoch",++ "status",++ "received_at"++ ],++ "isUnique": false++ },++ "idx_wechat_inbox_lease": {++ "name": "idx_wechat_inbox_lease",++ "columns": [++ "binding_epoch",++ "lease_until"++ ],++ "isUnique": false++ },++ "idx_wechat_inbox_conversation": {++ "name": "idx_wechat_inbox_conversation",++ "columns": [++ "binding_epoch",++ "peer_id",++ "conversation_epoch"++ ],++ "isUnique": false++ },++ "uniq_wechat_inbox_running_session": {++ "name": "uniq_wechat_inbox_running_session",++ "columns": [++ "binding_epoch",++ "session_id"++ ],++ "isUnique": true,++ "where": "\"wechat_inbox\".\"session_id\" IS NOT NULL AND \"wechat_inbox\".\"status\" IN ('dispatching', 'accepted_running', 'waiting_desktop', 'delivery_pending')"++ }++ },++ "foreignKeys": {++ "wechat_inbox_binding_epoch_wechat_sync_state_binding_epoch_fk": {++ "name": "wechat_inbox_binding_epoch_wechat_sync_state_binding_epoch_fk",++ "tableFrom": "wechat_inbox",++ "tableTo": "wechat_sync_state",++ "columnsFrom": [++ "binding_epoch"++ ],++ "columnsTo": [++ "binding_epoch"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ },++ "wechat_inbox_session_id_sessions_id_fk": {++ "name": "wechat_inbox_session_id_sessions_id_fk",++ "tableFrom": "wechat_inbox",++ "tableTo": "sessions",++ "columnsFrom": [++ "session_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "set null",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "wechat_outbox": {++ "name": "wechat_outbox",++ "columns": {++ "id": {++ "name": "id",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "binding_epoch": {++ "name": "binding_epoch",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "task_id": {++ "name": "task_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "client_id": {++ "name": "client_id",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "kind": {++ "name": "kind",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "chunk_index": {++ "name": "chunk_index",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "text": {++ "name": "text",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "media_json": {++ "name": "media_json",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'[]'"++ },++ "status": {++ "name": "status",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "'pending'"++ },++ "attempts": {++ "name": "attempts",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": 0++ },++ "next_retry_at": {++ "name": "next_retry_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "created_at": {++ "name": "created_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ },++ "delivered_at": {++ "name": "delivered_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ }++ },++ "indexes": {++ "uniq_wechat_outbox_client_id": {++ "name": "uniq_wechat_outbox_client_id",++ "columns": [++ "binding_epoch",++ "client_id"++ ],++ "isUnique": true++ },++ "idx_wechat_outbox_delivery": {++ "name": "idx_wechat_outbox_delivery",++ "columns": [++ "binding_epoch",++ "status",++ "next_retry_at"++ ],++ "isUnique": false++ },++ "idx_wechat_outbox_task": {++ "name": "idx_wechat_outbox_task",++ "columns": [++ "binding_epoch",++ "task_id",++ "chunk_index"++ ],++ "isUnique": false++ }++ },++ "foreignKeys": {++ "wechat_outbox_binding_epoch_wechat_sync_state_binding_epoch_fk": {++ "name": "wechat_outbox_binding_epoch_wechat_sync_state_binding_epoch_fk",++ "tableFrom": "wechat_outbox",++ "tableTo": "wechat_sync_state",++ "columnsFrom": [++ "binding_epoch"++ ],++ "columnsTo": [++ "binding_epoch"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ },++ "wechat_outbox_task_id_wechat_inbox_id_fk": {++ "name": "wechat_outbox_task_id_wechat_inbox_id_fk",++ "tableFrom": "wechat_outbox",++ "tableTo": "wechat_inbox",++ "columnsFrom": [++ "task_id"++ ],++ "columnsTo": [++ "id"++ ],++ "onDelete": "cascade",++ "onUpdate": "no action"++ }++ },++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ },++ "wechat_sync_state": {++ "name": "wechat_sync_state",++ "columns": {++ "binding_epoch": {++ "name": "binding_epoch",++ "type": "text",++ "primaryKey": true,++ "notNull": true,++ "autoincrement": false++ },++ "is_active": {++ "name": "is_active",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": false++ },++ "sync_cursor": {++ "name": "sync_cursor",++ "type": "text",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false,++ "default": "''"++ },++ "last_poll_at": {++ "name": "last_poll_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "last_error_code": {++ "name": "last_error_code",++ "type": "text",++ "primaryKey": false,++ "notNull": false,++ "autoincrement": false++ },++ "updated_at": {++ "name": "updated_at",++ "type": "integer",++ "primaryKey": false,++ "notNull": true,++ "autoincrement": false++ }++ },++ "indexes": {++ "uniq_wechat_sync_active": {++ "name": "uniq_wechat_sync_active",++ "columns": [++ "is_active"++ ],++ "isUnique": true,++ "where": "\"wechat_sync_state\".\"is_active\" = 1"++ }++ },++ "foreignKeys": {},++ "compositePrimaryKeys": {},++ "uniqueConstraints": {},++ "checkConstraints": {}++ }++ },++ "views": {},++ "enums": {},++ "_meta": {++ "schemas": {},++ "tables": {},++ "columns": {}++ },++ "internal": {++ "indexes": {++ "uniq_orca_worker_creation_reservations_team_label": {++ "columns": {++ "lower(\"label\")": {++ "isExpression": true++ }++ }++ },++ "uniq_orca_workers_team_label": {++ "columns": {++ "lower(\"label\")": {++ "isExpression": true++ }++ }++ }++ }++ }++}diff --cc apps/desktop/drizzle/meta/_journal.jsonindex 29352d2819,f6620e4eb6..e7c9447b06--- a/apps/desktop/drizzle/meta/_journal.json+++ b/apps/desktop/drizzle/meta/_journal.json@@@ -894,9 -894,9 +894,16 @@@{"idx": 127,"version": "6",- "when": 1791807544299,- "tag": "0127_thin_midnight",+ "when": 1792099140768,+ "tag": "0127_bot_group_task_posts",+ "breakpoints": true++ },++ {++ "idx": 128,++ "version": "6",++ "when": 1792121274542,++ "tag": "0128_demonic_odin",+ "breakpoints": true}]}diff --cc apps/desktop/src/main/bootstrap-electron.tsindex 7875d0d27b,3d2b6419c6..07ca72227d--- a/apps/desktop/src/main/bootstrap-electron.ts+++ b/apps/desktop/src/main/bootstrap-electron.ts@@@ -2471,10 -2503,12 +2507,14 @@@ authManager.setStableOwnerPostCommitTas// Signed-out is a real stable scope for account-free bundled provisioning.// Market and OAuth are owner-private follow-ups and stay behind this gate.if (dataOwnerId === null) return needsRetry ? 'failed' : 'completed';+ if (activeOwnerScopeKey() !== scopeKey || isAppSessionBoundaryPending()) return 'deferred';+ await refreshPluginUsageBindings();let deferred = false;- const marketOutcome = await syncDefaultMarketPlugins();+ const marketOutcome = await marketPostCommitStep.run(scopeKey, async () => {+ if (!isCurrent()) return 'deferred';+ return syncDefaultMarketPlugins();+ });+ if (!isCurrent()) return 'deferred';if (marketOutcome === 'failed') needsRetry = true;if (marketOutcome === 'deferred') deferred = true;diff --cc apps/desktop/src/main/localDb/__tests__/migrationReplay.test.tsindex 47834dc3f8,ab8bfe6e40..3073ceaf35--- a/apps/desktop/src/main/localDb/__tests__/migrationReplay.test.ts+++ b/apps/desktop/src/main/localDb/__tests__/migrationReplay.test.ts@@@ -106,13 -106,12 +106,15 @@@ describeMigrationReplay('migration replit.each(['missing', 'legacy', 'partial'])('replays remote report persistence with %s Worker schema', (shape) => {const { db, cleanup } = createTempDb();try {- db.exec("CREATE TABLE migration_meta (key TEXT PRIMARY KEY, value TEXT NOT NULL); CREATE TABLE migration_history (seq INTEGER PRIMARY KEY, file_name TEXT NOT NULL, content_hash TEXT NOT NULL, applied_at INTEGER NOT NULL)");+ // Later migrations need the sessions and task tables these Worker fixtures omit.+ db.exec("CREATE TABLE migration_meta (key TEXT PRIMARY KEY, value TEXT NOT NULL); CREATE TABLE migration_history (seq INTEGER PRIMARY KEY, file_name TEXT NOT NULL, content_hash TEXT NOT NULL, applied_at INTEGER NOT NULL); CREATE TABLE sessions (id TEXT PRIMARY KEY)");if (shape !== 'missing') db.exec(`CREATE TABLE orca_workers (id TEXT PRIMARY KEY${shape === 'partial' ? ', pending_remote_report TEXT' : ''}); INSERT INTO orca_workers (id) VALUES ('worker-1');`);+ db.exec("CREATE TABLE bot_delegations (id TEXT PRIMARY KEY)");const result = runMigrationReplay(db, { drizzleDir: drizzleDir(), currentVersion: 124 });- expect(result.applied.map((migration) => migration.seq)).toEqual([125, 126, 127]);- expect(result.applied.map((migration) => migration.seq)[0]).toBe(125);++ expect(result.applied.map((migration) => migration.seq)).toEqual([125, 126, 127, 128]);+ expect(tableExists(db, 'plugin_usage_subjects')).toBe(true);+ expect(tableExists(db, 'plugin_usage_events')).toBe(true);+ expect(db.prepare("SELECT name FROM sqlite_master WHERE type='index' AND name='plugin_usage_events_pending_idx'").get()).toEqual({ name: 'plugin_usage_events_pending_idx' });expect(tableExists(db, 'orca_remote_opens')).toBe(true);if (shape !== 'missing') {expect(columnNames(db, 'orca_workers')).toEqual(expect.arrayContaining(['pending_remote_report', 'remote_stop_confirmed_at']));diff --cc apps/desktop/src/main/localDb/client/__tests__/DbClient.inproc.test.tsindex cb98d5b006,63861d910c..1954eba0bd--- a/apps/desktop/src/main/localDb/client/__tests__/DbClient.inproc.test.ts+++ b/apps/desktop/src/main/localDb/client/__tests__/DbClient.inproc.test.ts@@@ -138,17 -137,6 +138,17 @@@ describe('DbClient in-proc fallback', (}),]);- const usageMigration = fs.readFileSync(new URL('../../../../../drizzle/0126_dazzling_pyro.sql', import.meta.url), 'utf8');++ const usageMigration = fs.readFileSync(new URL('../../../../../drizzle/0128_demonic_odin.sql', import.meta.url), 'utf8');+ for (const statement of usageMigration.split('--> statement-breakpoint').filter(s => s.trim())) await client.exec(statement);+ const identity = { ghostId: 'inproc-plugin', displayName: 'Test', revision: 'revision', sourceKind: 'manual' as const,+ stableKey: null, pluginId: null, organizationId: null, sourceKey: null, serverRoot: null, version: '1.0', releaseId: null };+ const bindUsage = { action: 'bind', identity, newId: 'inproc-subject', now: 1 } satisfies PluginUsageTransaction;+ const handle = await client.tx<PluginUsageHandle | null>('pluginUsage.execute', bindUsage);+ await client.tx('pluginUsage.execute', { action: 'accept', handle: handle!, callId: 'inproc-call', toolName: 'tool', sessionId: null, occurredAt: 2 });+ await client.tx('pluginUsage.execute', { action: 'clear', subjectId: handle!.subjectId, now: 3 });+ await client.tx('pluginUsage.execute', { action: 'settle', handle: handle!, callId: 'inproc-call', outcome: 'failed' });+ expect(await client.queryOne('SELECT COUNT(*) AS n FROM plugin_usage_events')).toEqual({ n: 0 });+const sourceId = `inproc-source-${Date.now()}`;await expect(client.tx('embedding.enqueue', {diff --cc apps/desktop/src/main/plugin-usage/__tests__/service.test.tsindex 3b5168a82d,0000000000..ef8c2c5320mode 100644,000000..100644--- a/apps/desktop/src/main/plugin-usage/__tests__/service.test.ts+++ b/apps/desktop/src/main/plugin-usage/__tests__/service.test.ts@@@ -1,613 -1,0 +1,613 @@@+import { readFileSync, mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'node:fs';+import os from 'node:os';+import path from 'node:path';+import { runMigrationReplay } from '../../localDb/migrationRunner';+import { buildDbWorkerBundle } from '../../localDb/__tests__/dbWorkerTestUtils';+import Database from 'better-sqlite3';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import { PluginUsageService } from '../service';+import { runPluginUsageTransaction } from '../../localDb/worker/opHandlers/pluginUsageTx';+import { createDbClient, type DbClient } from '../../localDb/client/DbClient';+import type { PluginUsageIdentity } from '../../../shared/pluginUsage';+import type { PluginUsageReporting } from '../reporter';+import { registerPluginUsageIpc } from '../ipc';+import { withGhostInstallLock } from '../../cindy-brain/ghostInstallLock';+import type { IpcMain, IpcMainInvokeEvent } from 'electron';++const identity: PluginUsageIdentity = {+ ghostId: 'test-plugin',+ displayName: 'Test',+ revision: 'rev1',+ sourceKind: 'manual',+ stableKey: null,+ pluginId: null,+ organizationId: null,+ sourceKey: null,+ serverRoot: null,+ version: '1.0',+ releaseId: null,+};+const migration = readFileSync(- new URL('../../../../drizzle/0126_dazzling_pyro.sql', import.meta.url),++ new URL('../../../../drizzle/0128_demonic_odin.sql', import.meta.url),+ 'utf8',+);+const now = Date.UTC(2026, 9, 12, 12);+const week = 168 * 60 * 60 * 1000;+let db: Database.Database;+let service: PluginUsageService;+let ownerCurrent: boolean;+let clock: number;+let client: DbClient;++beforeEach(() => {+ db = new Database(':memory:');+ db.pragma('foreign_keys=ON');+ db.exec(migration);+ db.exec('CREATE TABLE sessions (id TEXT PRIMARY KEY,title TEXT,status TEXT)');+ client = {+ tx: async (_name: string, args: unknown) => runPluginUsageTransaction(db, args),+ query: async (sql: string, params: unknown[] = []) => db.prepare(sql).all(...params),+ queryOne: async (sql: string, params: unknown[] = []) => db.prepare(sql).get(...params),+ } as DbClient;+ ownerCurrent = true;+ clock = now;+ service = new PluginUsageService({+ client,+ isCurrent: () => ownerCurrent,+ now: () => clock,+ deviceName: 'Test Mac',+ warn: vi.fn(),+ });+});+afterEach(async () => {+ await service.close();+ vi.useRealTimers();+ db.close();+});+const capture = () => service.capture(identity)!;++it('keeps one SQLite subject when a detail request overlaps the committed local upgrade', async () => {+ await service.bind(identity);+ const old = capture();+ service.accept(old, 'before-upgrade', 'tool', null, now - 2);+ const upgraded = { ...identity, revision: 'new-revision', version: '2.0' };+ const handlers = new Map<string, Parameters<IpcMain['handle']>[1]>();+ registerPluginUsageIpc({+ ipcMain: { handle: (name, fn) => handlers.set(name, fn) } as Pick<IpcMain, 'handle'>,+ assertTrusted: () => {},+ service: () => service,+ identity: () => upgraded,+ warn: vi.fn(),+ });+ let resume!: () => void;+ let entered!: () => void;+ const ready = new Promise<void>((r) => {+ entered = r;+ });+ const upgrade = withGhostInstallLock(identity.ghostId, async () => {+ entered();+ await new Promise<void>((r) => {+ resume = r;+ });+ await service.bind(upgraded, identity.revision);+ });+ await ready;+ const reading = handlers.get('ghosts:usage-summary')!({} as IpcMainInvokeEvent, identity.ghostId);+ resume();+ await upgrade;+ expect(await reading).toMatchObject({ subjectId: old.subjectId, totalCalls: 1 });+ service.accept(service.capture(upgraded)!, 'after-upgrade', 'tool', null, now - 1);+ expect((await service.summary(old.subjectId))?.totalCalls).toBe(2);+ expect(db.prepare('SELECT COUNT(*) AS n FROM plugin_usage_subjects').get()).toEqual({ n: 1 });+});++async function withReporting() {+ await service.close();+ vi.useFakeTimers();+ const target = {+ serverRoot: 'https://plugins.example',+ ownerId: 'owner',+ pluginId: 'plugin1',+ scope: 'public' as const,+ organizationId: null,+ };+ const reporting = {+ allowed: vi.fn(() => true),+ target: vi.fn(() => target),+ canSend: vi.fn(() => true),+ send: vi.fn<PluginUsageReporting['send']>(async (_target, events) => ({+ accepted: events.map((e) => e.eventId),+ duplicate: [],+ rejected: [],+ })),+ };+ service = new PluginUsageService({+ client,+ isCurrent: () => ownerCurrent,+ now: () => clock,+ deviceName: 'Test',+ warn: vi.fn(),+ reporting,+ });+ await service.bind(identity);+ return reporting;+}++it('resumes persisted pending rows on the next service and never recreates cleared data from an ACK', async () => {+ const reporting = await withReporting();+ const h = capture();+ service.accept(h, 'restart', 'tool', null, now);+ await service.close();+ service = new PluginUsageService({+ client,+ isCurrent: () => ownerCurrent,+ now: () => clock,+ deviceName: 'Test',+ warn: vi.fn(),+ reporting,+ });+ await vi.advanceTimersByTimeAsync(2500);+ expect(reporting.send).toHaveBeenCalledTimes(1);+ expect(db.prepare('SELECT report_state AS state FROM plugin_usage_events').get()).toEqual({+ state: 'sent',+ });+ const oldRow = {+ callId: 'restart',+ subjectId: h.subjectId,+ historyGeneration: h.historyGeneration,+ releaseId: 'release',+ occurredAt: now,+ reportTarget: JSON.stringify(h.reportTarget),+ attemptCount: 0,+ };+ await service.bind(identity);+ await service.clear(h.subjectId);+ service.accept(capture(), 'restart', 'tool', null, now);+ await service.summary(h.subjectId);+ runPluginUsageTransaction(db, {+ action: 'report',+ updates: [{ row: oldRow, state: 'sent', nextAttemptAt: null }],+ });+ expect(+ db+ .prepare(+ 'SELECT report_state AS state,history_generation AS generation FROM plugin_usage_events',+ )+ .get(),+ ).toEqual({ state: 'pending', generation: 1 });+});++it('persists the frozen target, batches at most 100, and confirms only ACKed events without deleting history', async () => {+ const reporting = await withReporting();+ reporting.send.mockImplementationOnce(async (_target, events) => ({+ accepted: [events[0].eventId],+ duplicate: [events[1].eventId],+ rejected: [{ eventId: events[2].eventId, code: 'FUTURE_REASON' }],+ }));+ const h = capture();+ h.identity.releaseId = 'release-1';+ for (let i = 0; i < 101; i++)+ service.accept(h, `call-${i}`, 'tool', 'private-task', now - 1000 + i);+ await service.summary(h.subjectId);+ await vi.advanceTimersByTimeAsync(2500);+ expect(reporting.send).toHaveBeenCalledTimes(1);+ expect(reporting.send.mock.calls[0][1]).toHaveLength(100);+ expect(reporting.send.mock.calls[0][1][0]).toEqual({+ eventId: 'call-0',+ releaseId: 'release-1',+ occurredAt: new Date(now - 1000).toISOString(),+ });+ expect(+ db+ .prepare(+ 'SELECT report_state AS state,COUNT(*) AS n FROM plugin_usage_events GROUP BY report_state ORDER BY state',+ )+ .all(),+ ).toEqual([+ { state: 'pending', n: 99 },+ { state: 'sent', n: 2 },+ ]);+ expect((await service.summary(h.subjectId))?.totalCalls).toBe(101);+});++it('does not upload disabled-period calls or replay historical not-applicable rows after enabling', async () => {+ const reporting = await withReporting();+ reporting.allowed.mockReturnValue(false);+ service.accept(capture(), 'disabled', 'tool', null, now);+ await service.summary(capture().subjectId);+ reporting.allowed.mockReturnValue(true);+ await vi.advanceTimersByTimeAsync(2500);+ expect(reporting.send).not.toHaveBeenCalled();+ expect(db.prepare('SELECT report_state AS state FROM plugin_usage_events').get()).toEqual({+ state: 'not-applicable',+ });+});++it('retains personal history and retries the identical event after a missing endpoint', async () => {+ const reporting = await withReporting();+ reporting.send.mockRejectedValueOnce({ statusCode: 404 });+ const h = capture();+ service.accept(h, 'retry', 'tool', null, now);+ await service.summary(h.subjectId);+ await vi.advanceTimersByTimeAsync(2500);+ expect(+ db+ .prepare(+ 'SELECT report_state AS state,attempt_count AS attempts,next_attempt_at AS next FROM plugin_usage_events',+ )+ .get(),+ ).toEqual({ state: 'pending', attempts: 1, next: now + 300_000 });+ clock += 300_000;+ await vi.advanceTimersByTimeAsync(300_000);+ expect(reporting.send).toHaveBeenCalledTimes(2);+ expect(reporting.send.mock.calls[1][1]).toEqual(reporting.send.mock.calls[0][1]);+ expect((await service.summary(h.subjectId))?.totalCalls).toBe(1);+});++it('splits a 413 batch while preserving event facts and personal history', async () => {+ const reporting = await withReporting();+ reporting.send.mockRejectedValueOnce({ statusCode: 413 });+ const h = capture();+ h.identity.releaseId = 'release-1';+ for (let i = 0; i < 4; i++) service.accept(h, `split-${i}`, 'tool', null, now - 4 + i);+ await service.summary(h.subjectId);+ await vi.advanceTimersByTimeAsync(2500);+ expect(reporting.send.mock.calls[0][1]).toHaveLength(4);+ expect(+ db.prepare("SELECT COUNT(*) AS n FROM plugin_usage_events WHERE report_state='pending'").get(),+ ).toEqual({ n: 4 });+ clock += 2500;+ await vi.advanceTimersByTimeAsync(2500);+ clock += 2500;+ await vi.advanceTimersByTimeAsync(2500);+ expect(reporting.send.mock.calls.map((call) => call[1].length)).toEqual([4, 2, 2]);+ expect(reporting.send.mock.calls.slice(1).flatMap((call) => call[1])).toEqual(+ reporting.send.mock.calls[0][1],+ );+ expect(+ db.prepare("SELECT COUNT(*) AS n FROM plugin_usage_events WHERE report_state='sent'").get(),+ ).toEqual({ n: 4 });+ expect((await service.summary(h.subjectId))?.totalCalls).toBe(4);+});++it('backs off a single-event 413 without deleting it or retrying in a tight loop', async () => {+ const reporting = await withReporting();+ reporting.send.mockRejectedValueOnce({ statusCode: 413 });+ const h = capture();+ service.accept(h, 'single-413', 'tool', null, now);+ await service.summary(h.subjectId);+ await vi.advanceTimersByTimeAsync(2500);+ clock += 10_000;+ await vi.advanceTimersByTimeAsync(10_000);+ expect(reporting.send).toHaveBeenCalledTimes(1);+ expect(+ db+ .prepare('SELECT report_state AS state,next_attempt_at AS next FROM plugin_usage_events')+ .get(),+ ).toEqual({ state: 'pending', next: now + 60_000 });+ expect((await service.summary(h.subjectId))?.totalCalls).toBe(1);+});++it.each(['clear', 'owner', 'close'] as const)(+ 'does not apply a late network ACK after %s',+ async (action) => {+ const reporting = await withReporting();+ let resolve!: (value: Awaited<ReturnType<PluginUsageReporting['send']>>) => void;+ reporting.send.mockImplementationOnce(+ () =>+ new Promise((r) => {+ resolve = r;+ }),+ );+ const h = capture();+ service.accept(h, 'late-ack', 'tool', null, now);+ await service.summary(h.subjectId);+ await vi.advanceTimersByTimeAsync(2500);+ if (action === 'clear') await service.clear(h.subjectId);+ else if (action === 'owner') ownerCurrent = false;+ else await service.close();+ resolve({ accepted: ['late-ack'], duplicate: [], rejected: [] });+ await vi.advanceTimersByTimeAsync(3000);+ expect(+ db.prepare("SELECT COUNT(*) AS n FROM plugin_usage_events WHERE report_state='sent'").get(),+ ).toEqual({ n: 0 });+ expect(reporting.send).toHaveBeenCalledTimes(1);+ if (action === 'clear')+ expect(db.prepare('SELECT COUNT(*) AS n FROM plugin_usage_events').get()).toEqual({ n: 0 });+ },+);++it('counts unique dispatched calls over a rolling 168h window without deleting older events', async () => {+ await service.bind(identity);+ const h = capture();+ for (const [id, time] of [+ ['older', now - week - 1],+ ['boundary', now - week],+ ['recent', now - 1],+ ['future', now],+ ] as const)+ service.accept(h, id, 'top_tool', null, time);+ service.accept(h, 'recent', 'top_tool', 'forged-title-never-stored', now - 1);+ service.settle(h, 'recent', 'failed');+ expect(await service.summary(h.subjectId)).toMatchObject({+ totalCalls: 4,+ callsLast7Days: 2,+ lastUsedAt: now,+ recentTasks: [],+ });+ expect(+ db+ .prepare(+ 'SELECT outcome,session_id AS sessionId,version,report_state AS state FROM plugin_usage_events WHERE call_id=?',+ )+ .get('recent'),+ ).toEqual({ outcome: 'failed', sessionId: null, version: '1.0', state: 'not-applicable' });+});++it('deduplicates tasks after filtering deletion and reads current titles; calls survive task deletion', async () => {+ await service.bind(identity);+ const h = capture();+ for (let i = 1; i <= 5; i++) {+ db.prepare('INSERT INTO sessions VALUES (?,?,?)').run(+ `s${i}`,+ `Title ${i}`,+ i === 5 ? 'deleted' : 'active',+ );+ service.accept(h, `c${i}`, 'tool', `s${i}`, now - (10 - i));+ }+ service.accept(h, 'duplicate-session', 'tool', 's4', now - 1);+ db.prepare('UPDATE sessions SET title=? WHERE id=?').run('Renamed', 's4');+ expect(+ (await service.summary(h.subjectId))?.recentTasks.map((t) => [t.sessionId, t.title]),+ ).toEqual([+ ['s4', 'Renamed'],+ ['s3', 'Title 3'],+ ['s2', 'Title 2'],+ ]);+ db.prepare('DELETE FROM sessions WHERE id=?').run('s4');+ expect(await service.summary(h.subjectId)).toMatchObject({+ totalCalls: 6,+ recentTasks: [{ sessionId: 's3' }, { sessionId: 's2' }, { sessionId: 's1' }],+ });+});++it('atomically clears one subject, rejects old-generation inserts/results, then accepts new calls', async () => {+ await service.bind(identity);+ const old = capture();+ const other = { ...identity, ghostId: 'other', revision: 'other-rev' };+ await service.bind(other);+ const h2 = service.capture(other)!;+ service.accept(old, 'old', 'tool', null, now - 1);+ service.accept(h2, 'keep', 'tool', null, now - 1);+ await service.clear(old.subjectId);+ service.accept(old, 'late-accept', 'tool', null, now);+ service.settle(old, 'old', 'succeeded');+ expect(await service.summary(old.subjectId)).toMatchObject({+ totalCalls: 0,+ recordingStartedAt: now,+ });+ const next = capture();+ expect(next.historyGeneration).toBe(old.historyGeneration + 1);+ service.accept(next, 'new', 'tool', null, now - 1);+ expect((await service.summary(next.subjectId))?.totalCalls).toBe(1);+ expect((await service.summary(h2.subjectId))?.totalCalls).toBe(1);+ await service.clear(null);+ expect(db.prepare('SELECT COUNT(*) AS n FROM plugin_usage_events').get()).toEqual({ n: 0 });+});++it('rejects writes with stale generations cleared by another connection/service without replay', async () => {+ await service.bind(identity);+ const stale = capture();+ runPluginUsageTransaction(db, { action: 'clear', subjectId: stale.subjectId, now });+ service.accept(stale, 'old-generation', 'tool', null, now - 1);+ expect((await service.summary(stale.subjectId))?.totalCalls).toBe(0);+ service.accept(capture(), 'fresh', 'tool', null, now - 1);+ expect((await service.summary(stale.subjectId))?.totalCalls).toBe(1);+});++it('keeps local upgrades continuous but separates reinstallations; verified market reinstallation rejoins', async () => {+ await service.bind(identity);+ const h = capture();+ service.accept(h, 'v1', 'tool', null, now - 2);+ const upgraded = { ...identity, revision: 'rev2', version: '2.0' };+ await service.bind(upgraded, identity.revision);+ const h2 = service.capture(upgraded)!;+ expect(h2.subjectId).toBe(h.subjectId);+ service.accept(h2, 'v2', 'tool', null, now - 1);+ const rollback = { ...identity, revision: 'rollback' };+ await service.bind(rollback, upgraded.revision);+ const rollbackHandle = service.capture(rollback)!;+ expect(rollbackHandle.subjectId).toBe(h.subjectId);+ service.accept(rollbackHandle, 'rollback-call', 'tool', null, now);+ await service.detach(identity.ghostId);+ const reinstalled = { ...upgraded, revision: 'rev3' };+ await service.bind(reinstalled);+ expect(service.capture(reinstalled)?.subjectId).not.toBe(h.subjectId);+ const market = {+ ...identity,+ sourceKind: 'server' as const,+ stableKey: 'verified-server/plugin1',+ pluginId: 'plugin1',+ serverRoot: 'https://plugins.example',+ revision: 'market1',+ };+ await service.bind(market);+ const mh = service.capture(market)!;+ await service.detach(market.ghostId);+ await service.bind({ ...market, revision: 'market2' });+ expect(service.capture({ ...market, revision: 'market2' })?.subjectId).toBe(mh.subjectId);+ expect(db.prepare('SELECT version FROM plugin_usage_events ORDER BY occurred_at').all()).toEqual([+ { version: '1.0' },+ { version: '2.0' },+ { version: '1.0' },+ ]);+});++it('does not run queued operations after the owner/client epoch changes, including global inproc handles', async () => {+ await service.bind(identity);+ const h = capture();+ let resume!: () => void;+ const realTx = client.tx.bind(client);+ const txSpy = vi.spyOn(client, 'tx').mockImplementationOnce(async (name, args) => {+ await new Promise<void>((r) => {+ resume = r;+ });+ return realTx(name, args);+ });+ const pendingBind = service.bind(identity).catch(() => undefined);+ await Promise.resolve();+ service.accept(h, 'old-owner', 'tool', null, now);+ ownerCurrent = false;+ resume();+ await pendingBind;+ await service.close();+ expect(txSpy).toHaveBeenCalledTimes(1);+ expect(db.prepare('SELECT COUNT(*) AS n FROM plugin_usage_events').get()).toEqual({ n: 0 });+ expect(service.capture(identity)).toBeNull();+});++it('close stops admission and drains already accepted short writes', async () => {+ await service.bind(identity);+ const h = capture();+ service.accept(h, 'before-close', 'tool', null, now - 1);+ await service.close();+ service.accept(h, 'after-close', 'tool', null, now);+ expect(db.prepare('SELECT call_id FROM plugin_usage_events').all()).toEqual([+ { call_id: 'before-close' },+ ]);+});++describe('actual async DbClient inline worker', () => {+ it('uses the same generated migration and transaction contract in the worker', async () => {+ const worker = await createDbClient({ useInlineWorker: true });+ try {+ for (const statement of migration.split('--> statement-breakpoint').filter((s) => s.trim()))+ await worker.exec(statement);+ const h = await worker.tx('pluginUsage.execute', {+ action: 'bind',+ identity,+ newId: 'worker-subject',+ now,+ });+ await worker.tx('pluginUsage.execute', {+ action: 'accept',+ handle: h!,+ callId: 'worker-call',+ toolName: 'tool',+ sessionId: null,+ occurredAt: now,+ });+ await worker.tx('pluginUsage.execute', { action: 'clear', subjectId: h!.subjectId, now });+ await worker.tx('pluginUsage.execute', {+ action: 'accept',+ handle: h!,+ callId: 'late-worker-call',+ toolName: 'tool',+ sessionId: null,+ occurredAt: now,+ });+ expect(await worker.queryOne('SELECT COUNT(*) AS n FROM plugin_usage_events')).toEqual({+ n: 0,+ });+ expect(+ await worker.queryOne('SELECT history_generation AS generation FROM plugin_usage_subjects'),+ ).toEqual({ generation: 1 });+ } finally {+ await worker.dispose();+ }+ });+});++it('uses persisted generations across two independent SQLite connections', () => {+ const dir = mkdtempSync(path.join(os.tmpdir(), 'plugin-usage-generation-'));+ const first = new Database(path.join(dir, 'history.db'));+ first.exec(migration);+ const second = new Database(path.join(dir, 'history.db'));+ try {+ const h = runPluginUsageTransaction(first, {+ action: 'bind',+ identity,+ newId: 'subject',+ now,+ })!;+ runPluginUsageTransaction(second, { action: 'clear', subjectId: h.subjectId, now });+ runPluginUsageTransaction(first, {+ action: 'accept',+ handle: h,+ callId: 'stale',+ toolName: 'tool',+ sessionId: null,+ occurredAt: now,+ });+ runPluginUsageTransaction(first, {+ action: 'settle',+ handle: h,+ callId: 'stale',+ outcome: 'succeeded',+ });+ expect(second.prepare('SELECT COUNT(*) AS n FROM plugin_usage_events').get()).toEqual({ n: 0 });+ } finally {+ first.close();+ second.close();+ rmSync(dir, { recursive: true, force: true });+ }+});+it('runs usage transactions in the bundled file worker, not only its inline fallback', async () => {+ const dir = mkdtempSync(path.join(os.tmpdir(), 'plugin-usage-worker-'));+ let worker: DbClient | undefined;+ try {+ const drizzleDir = path.join(dir, 'drizzle');+ mkdirSync(drizzleDir);+ writeFileSync(path.join(drizzleDir, '0000_init.sql'), migration);+ const raw = new Database(path.join(dir, 'history.db'));+ raw.exec(+ 'CREATE TABLE migration_meta (key TEXT PRIMARY KEY,value TEXT); CREATE TABLE migration_history (seq INTEGER PRIMARY KEY,file_name TEXT NOT NULL,content_hash TEXT NOT NULL,applied_at INTEGER NOT NULL)',+ );+ runMigrationReplay(raw, { drizzleDir, currentVersion: -1 });+ raw.close();+ const workerScriptPath = await buildDbWorkerBundle(path.join(dir, 'bundle'));+ worker = await createDbClient({+ dbPath: path.join(dir, 'history.db'),+ drizzleDir,+ workerScriptPath,+ betterSqliteModulePath: require.resolve('better-sqlite3'),+ });+ const h = await worker.tx('pluginUsage.execute', {+ action: 'bind',+ identity,+ newId: 'file-worker-subject',+ now,+ });+ await worker.tx('pluginUsage.execute', {+ action: 'accept',+ handle: h!,+ callId: 'file-worker-call',+ toolName: 'tool',+ sessionId: null,+ occurredAt: now,+ });+ expect(await worker.queryOne('SELECT COUNT(*) AS n FROM plugin_usage_events')).toEqual({+ n: 1,+ });+ } finally {+ await worker?.dispose();+ rmSync(dir, { recursive: true, force: true });+ }+}, 60_000);++it('counts and clears tool calls separately for same-name namespace instances', async () => {+ const root = { ...identity, ghostId: 'same-name' };+ const org = { ...identity, ghostId: '_ns__acme__same-name' };+ await service.bind(root);+ await service.bind(org);+ const rootHandle = service.capture(root)!;+ const orgHandle = service.capture(org)!;+ expect(rootHandle.subjectId).not.toBe(orgHandle.subjectId);+ service.accept(rootHandle, 'root-call', 'tool', null, now - 1);+ service.accept(orgHandle, 'org-call', 'tool', null, now - 1);+ expect(await service.summary(rootHandle.subjectId)).toMatchObject({ totalCalls: 1 });+ expect(await service.summary(orgHandle.subjectId)).toMatchObject({ totalCalls: 1 });+ await service.clear(rootHandle.subjectId);+ expect(await service.summary(rootHandle.subjectId)).toMatchObject({ totalCalls: 0 });+ expect(await service.summary(orgHandle.subjectId)).toMatchObject({ totalCalls: 1 });+});diff --cc apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsxindex 0f735f4c51,e605a8e57e..788ed75016--- a/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx+++ b/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx@@@ -28,11 -28,8 +28,11 @@@ import} from 'lucide-react';import { useTranslation } from 'react-i18next';- import { CindyCapabilityPrefs } from '@/cindy-brain/CindyCapabilityPrefs';+import { PluginUsageCard } from './PluginUsageCard';+import { PluginSharedUsage } from './PluginSharedUsage';+import type { PluginMarketItem } from '../../../shared/pluginMarket';import { GhostLibrarySection } from './GhostLibrarySection';+ import { PluginBackgroundTasksSection } from './PluginBackgroundTasksSection';import { PluginTaskPrefs } from '@/cindy-brain/PluginTaskPrefs';import { GhostSettingsWebview } from '@/cindy-brain/GhostSettingsWebview';import { WINDOW_NO_DRAG_STYLE } from '@/components/layout/windowDrag';diff --cc docs/acceptance/plugin-statistics-pr/README.mdindex 05859cb898,0000000000..cbd2335448mode 100644,000000..100644--- a/docs/acceptance/plugin-statistics-pr/README.md+++ b/docs/acceptance/plugin-statistics-pr/README.md@@@ -1,38 -1,0 +1,47 @@@+# 插件统计客户端验收摘要++本目录只公开必要真实截图与核对摘要,不包含原始日志、凭证、用户路径、测试启动脚本或隐藏宿主补丁。用户已确认设计、实现截图与列表/个人卡样式。++## 真实页面与版本++| 页面 | 截图 |+| --- | --- |+| 列表深色 | [列表](screenshots/list-dark.png) |+| 个人详情浅色 | [详情](screenshots/personal-light.png) |+| 个人详情深色 | [详情](screenshots/personal-dark.png) |++三图 renderer 完整源码为 46f937a39117ded3ef0fac4874d6e37a276c81ac;初始 main/preload/协议由 97b9ff46cad27a76689928d1b088a16a2412d419 完整冷构建并 ready。46f 仅删失效文案与注释,main/preload/协议不变,通过正常 HMR/reload 拍图,不声称 46f 冷启动。TypeScript 去注释 emitted JS、CSS 规则与除四个删除键外的五种语言资源等价;截图 SHA256 见 [screenshots.json](screenshots.json)。测试壳仅限制验收窗口可见性、焦点和原生 dialog,没有进入产品提交。完整验收源码与测试壳差异独立核对,不能把实际壳 SHA 误作产品 SHA。++列表只有一个真实联调插件,fixture 没有作者;列表浅色在更早的 73b7 UI 基线已目检,本次清理只重拍深色。截图中共享调用 6、滚动 168h 调用 6、下载 URL 请求 3、个人调用 3,来自隔离业务源,不是设计数字。后端使用冻结历史版本的隔离联调资源,不代表 PR #887 已部署。++## 已验证++- 列表展示范围与下载,详情版本旁下载与累计使用;个人无分割线、标题右侧清除,双主题无溢出。+- 97b9 卡片样式冷启动 computed style:标题 14/500/20、时间/次数 14/400/20、标签 12/400/16;padding 16、border 1、radius 12、间距 12/4/16;跟随父内容区,标准/800/700 窗口卡宽 760/451/367,当前内容自然高 114。+- 正常打开清除确认并取消,完整个人 summary 不变;没有清除真实历史。成功清除的事务与代际语义由隔离 fixture 回归覆盖。+- 更早 UI 基线覆盖已安装/市场已安装预览、700/800 窄宽及共享头部 hover;真实未安装、作者、零/缺失与大整数以组件测试覆盖,不冒称实机数据验证。+- 定向 namespace 回归覆盖同 ghostId 不同实例的读取、清除和来源回填隔离;不冒称真实多 namespace 插件 E2E。+- 46f 清理 103 项 UI/排版测试、类型检查、renderer lint/i18n 通过,三图逐张目检;原始本地证据与索引保留。++## 发布整合与限制++发布准备在 46f 上合入 canonical main c950b504649f2c64668c618320c352d159370961。主干未改变 migration/schema/锁文件,0126/0127 无撞号,三处测试 mock 合并保留双方新增接口。发布前已运行 52 文件 1072 项 Desktop 定向测试、协议包 165 项测试/类型构建、Desktop 类型检查、迁移静态校验及 14 项回放;当前截图不冒称整合后冷启动截图,统计组件/样式与 46f 相同。++本地全量门禁未执行,等待 PR CI。此次按已授权的影响面验证,未重跑无关整仓;独立 review、评分及插件基座指定 Approve 仍为合并前门禁。真实键盘激活、其他字号档位和长外语布局未验证;本轮未操作正式 profile、宿主、生产服务或数据。++## 首轮审核修复(2026-10-14)++c4aae2ad9 的 CI 中,两平台四分片共用的 6 项失败已在本地复现:账号退出的顺序断言漏了调用统计 flush,安装/卸载回调夹具漏了新增统计依赖。修复保留生产关闭、两类 flush、数据库释放及插件绑定/解绑行为;不改 main 产品代码。++个人卡改为可见时每 5 秒查询本地统计,隐藏暂停、恢复可见即刷新。同一轮不重叠,清除确认期间不启动自动查询,离开实例或清除后不接受旧响应。新增 4 项回归在旧代码上失败;最终 7 文件 95 项测试、Desktop 类型检查及本轮 6 文件 ESLint 通过。卡片渲染和样式源码逐字未变,以上截图仍只说明原版本外观。++本轮未恢复用户已停止的沙盒,未重新执行真实后台调用或实机轮询验收;自动刷新由挂载组件与 IPC 夹具回归覆盖。本地全量门禁未执行,新 head CI 与评分需重新取得。停止前 c4 main/preload/renderer 完整冷启动及三图验收实际已完成,独立 23 文件索引已核对;该记录不能算作本轮刷新修复的 runtime 验收。++++++## 主干冲突整合(2026-10-16)++++基于首轮修复 2d8468b9 合入 canonical main a1fbbb8ec7d1476813b5ae57ef56e86dc3d21260。保留主干的 0126_melodic_toxin、0127_bot_group_task_posts 及对应元数据;统计 schema 由 Drizzle 重新生成 0128_demonic_odin,一次创建两张表和待上报部分索引。临时 SQLite 对比确认其最终表/索引结构与原两条统计迁移完全一致,主干历史迁移保持原样。两处直接读取迁移的测试夹具同步到新文件名。详情导入保留统计组件及主干的统一模型设置、后台任务区,没有新增样式调整。++++验证:Desktop 60 文件 1163 项通过,另 15 项实际迁移回放通过;协议 11 文件 166 项与类型构建通过;迁移静态冻结/连续/journal/schema/CJS 校验覆盖 0000..0128;Desktop 类型检查、本轮四个冲突或夹具 TS/TSX 文件 ESLint、公开 tracked-file 文档检查 10/10 通过。首轮定向运行发现统计服务夹具引用旧迁移导致 ENOENT,修正后该服务 21 项及 DbClient 真实 Worker/回退调用通过,不将首次失败隐去。++++本轮未恢复已停止的沙盒,没有新 UI 截图或冷启动验收;上述历史截图及 c4 冷启动保留原版本边界。未发布的旧统计迁移身份已被替换,曾运行旧分支迁移的测试 profile 不能直接当成新版兼容验收数据;不修改或迁移该 profile。新提交的 CI、评分及指定 Approve 需独立核对,旧 2d8468b9 的 CI/5 分/Approve 不冒称覆盖新提交。本地全量门禁未执行,等待 PR CI。diff --cc docs/acceptance/plugin-statistics-pr/checks.jsonindex e2e67ab7bf,0000000000..429fc818d8mode 100644,000000..100644--- a/docs/acceptance/plugin-statistics-pr/checks.json+++ b/docs/acceptance/plugin-statistics-pr/checks.json@@@ -1,59 -1,0 +1,100 @@@+{+ "acceptedSource": "46f937a39117ded3ef0fac4874d6e37a276c81ac",+ "integrationSource": "c2041018d21ab18f55e9ee0881abfdb50eca436a",+ "canonicalBase": "c950b504649f2c64668c618320c352d159370961",+ "checks": {+ "desktopTargeted": {+ "files": 52,+ "passed": 1072,+ "exitCode": 0+ },+ "desktopTypecheck": {+ "exitCode": 0+ },+ "protocolTest": {+ "files": 11,+ "passed": 165,+ "exitCode": 0+ },+ "protocolBuild": {+ "exitCode": 0+ },+ "migrationStatic": {+ "range": "0000..0127",+ "exitCode": 0+ },+ "migrationReplay": {+ "passed": 14,+ "exitCode": 0+ },+ "i18n": {+ "exitCode": 0,+ "existingWarnings": true+ },+ "glossary": {+ "exitCode": 0+ },+ "publicTrackedDocs": {+ "passed": 10,+ "exitCode": 0+ },+ "desktopChangedFilesESLint": {+ "files": 43,+ "exitCode": 1,+ "errors": 33,+ "introducedErrors": 0,+ "baseline": "c950b504649f2c64668c618320c352d159370961",+ "comparison": "ruleId/message/source-line equality"+ },+ "diffCheck": {+ "exitCode": 0+ }+ },+ "limitations": [+ "Local full suite not run; full CI pending",+ "Root docs check fails on existing untracked local evidence-copy links; public tracked-file snapshot passes without modifying local originals",+ "No independent review or numerical score yet",+ "Screenshot renderer source 46f; initial main ready 97b; no claim of integration-source cold start"- ]++ ],++ "conflictIntegration20261016": {++ "canonicalBase": "a1fbbb8ec7d1476813b5ae57ef56e86dc3d21260",++ "previousHead": "2d8468b9f4a4258ee9300bdb90a27f5d21b18fca",++ "migration": "0128_demonic_odin",++ "migrationSchemaEquivalentToPrevious": true,++ "desktopTargeted": {++ "files": 60,++ "passed": 1163,++ "exitCode": 0++ },++ "migrationStatic": {++ "range": "0000..0128",++ "exitCode": 0++ },++ "migrationReplay": {++ "passed": 15,++ "exitCode": 0++ },++ "desktopTypecheck": {++ "exitCode": 0++ },++ "protocolTest": {++ "files": 11,++ "passed": 166,++ "exitCode": 0++ },++ "protocolBuild": {++ "exitCode": 0++ },++ "conflictAndFixtureESLint": {++ "files": 4,++ "exitCode": 0++ },++ "publicTrackedDocs": {++ "passed": 10,++ "exitCode": 0++ },++ "firstRunFailure": "Service fixture referenced removed unmerged migration; updated two fixture paths, service 21 tests and DbClient integration then passed",++ "runtimeAcceptance": "Not rerun; stopped sandbox remains stopped",++ "localFullSuite": "Not run; full PR CI required"++ }+}diff --cc docs/plugin-usage-statistics-implementation.mdindex ab7341bfdd,0000000000..8f7824bf1amode 100644,000000..100644--- a/docs/plugin-usage-statistics-implementation.md+++ b/docs/plugin-usage-statistics-implementation.md@@@ -1,41 -1,0 +1,43 @@@+# 插件调用统计:客户端实施说明++本功能保留当前电脑、当前账户的个人调用记录,并在插件目录提供授权共享统计时展示下载和使用次数。设计与真实 UI 已由用户确认;服务端独立交付见 [cindy-server PR #887](https://github.com/xindong/cindy-server/pull/887),此说明不代表生产服务已部署。++## 个人记录++- GhostPipeDispatcher 通过可见性、启用、工具声明、权限及账户检查,且 sendToGhost 接受派发后计一次;已有 callId 去重。派发后的失败、超时或取消只更新 outcome,不增加次数;调试入口不计。- - 账户 SQLite 追加 plugin_usage_subjects 与 plugin_usage_events。0126_dazzling_pyro 建表,0127_thin_midnight 添加待上报索引。历史 migration 不修改;7 日窗口是滚动 168 小时的查询条件,不是记录保存期限。++- 账户 SQLite 追加 plugin_usage_subjects 与 plugin_usage_events。0128_demonic_odin 一次创建两张表及待上报部分索引;基于主干既有 0126/0127 由 Drizzle 重新生成。历史 migration 不修改;7 日窗口是滚动 168 小时的查询条件,不是记录保存期限。+- 参数、结果正文和凭证不进入记录。个人明细保留宿主工具名、任务引用、版本/发布身份与结果状态,不作为计费级审计。+- 普通升级/回滚保留连续安装主体;本地卸载重装分开,来源可验证的市场重装延续主体。禁用、卸载及任务删除不删除历史。+- 绑定、派发和查询使用实际实例键;市场账本按真实 namespace 精确查来源。同名根/组织实例不能借用另一份记录或来源。旧无 namespace 安装继续沿既有 helper 的兼容路径工作,不要求重装、重新批准或配置。+- owner/clientEpoch 与 historyGeneration 隔离切号和清除。清除在一个 worker 事务中递增代际并删除明细,迟到结果只 UPDATE;旧句柄不重放。++## 可选共享统计与上报++- 下载来自 downloadStatistics.requestCount:成功取得下载 URL 的次数,包含升级、重装和再次取票,**不是成功安装量**。没有成功安装字段或估算。+- 使用来自 usageStatistics={usageCount,usageCountLast7Days,asOf};非负十进制字符串按 BigInt 显示,缺失/非法指标独立隐藏,真实 0 显示。schemaVersion 仍为 2,旧服务省略字段不会破坏目录或安装功能。+- public/organization 只消费原有授权目录响应;组织的成员、角色、部门门禁不扩大。local/custom 不因为显示 public 标签而进入共享范围。共享读取缓存 60 秒,不缓存个人查询。+- 仅在当前账户、非 local 模式、允许分析数据且来源账本与安装字节身份验证通过时,为新派发冻结 reportTarget。发送前再次核对 owner、服务根和来源;不跨服务根重试、不借用后来登录账户。+- wire 回执仅发送 eventId、releaseId、occurredAt;不发送工具名、任务 ID、参数/结果正文或凭证。SQLite 原记录保存 pending/sent/rejected 状态,批量 ACK/duplicate 去重、退避重试;不开文件 outbox,不补传未取得合法目标的旧记录。+- 关闭分析数据后暂停发送;切号/退出在数据库关闭前有界收尾。崩溃、磁盘故障或尚未绑定的派发可能漏记,不承诺 exactly-once。+- 旧服务未实现回执端点时退避保留 pending;共享字段缺失时 UI 隐藏。个人清除不撤销已被服务端接收的聚合记录。++## 已确认 UI++- 列表灰字保留范围、作者(存在时)与累计下载,移出版本和机器 ID。+- 已安装和市场详情的版本旁显示累计共享下载与使用;内容区不超过 520px 时 metadata 放到 hero 下一整行。+- 个人卡只展示最近调用、近 7 日调用,没有任务列表、图标、分割线、更多菜单或正常态刷新按钮;清除直接放标题右侧,保留确认与取消,失败态仍可重试。卡片保持打开时每 5 秒查询本地统计,隐藏时暂停、再次可见时读取;同一轮查询不重叠,离开实例或清除后的旧响应不覆盖新读数。+- 使用既有语义 token,双主题实现。标题 14/500/20,时间与次数 14/400/20,标签 12/400/16;padding 16、容器圆角 12、描边 1、间距 12/4/16。卡片跟随父内容宽度、自然高度,字号和行高随既有设置缩放。++真实截图及受测版本边界见 [公开验收摘要](acceptance/plugin-statistics-pr/README.md)。图片为隔离 Electron 中真实页面,不是生成稿或伪造统计。++## 验证与交付边界+- 发布准备基于用户验收的 46f937a39117ded3ef0fac4874d6e37a276c81ac,合入 canonical main c950b504649f2c64668c618320c352d159370961。主干没有 migration/schema/锁文件变化,0126/0127 未撞号;三个测试 mock 的合并保留统计绑定与旧作品库接回两套接口,产品代码自动合并后复核。++首次发布准备基于用户验收的 46f937a39117ded3ef0fac4874d6e37a276c81ac,合入 canonical main c950b504649f2c64668c618320c352d159370961。当时主干没有 migration/schema/锁文件变化,0126/0127 未撞号;三个测试 mock 的合并保留统计绑定与旧作品库接回两套接口,产品代码自动合并后复核。++++2026-10-16 继续合入 canonical main a1fbbb8ec:保留主干既有 0126/0127,Drizzle 重新生成统计迁移 0128;保留主干统一模型设置和后台任务区,以及个人/共享统计组件。只在临时数据库验证新迁移,不复用曾写入旧统计迁移的隔离 profile。最新验证与历史截图边界见公开验收摘要。++整合后的定向测试包括个人记录/回执、市场/账本、派发器、实例/namespace 与旧作品库边界、DbClient 和插件 UI;协议包全测试/类型构建、Desktop 类型检查、migration 静态校验和真实回放另列在 PR。针对修改文件执行 lint/i18n/术语与 DCO 检查,既有失败需披露,不能称整仓全绿。++未提供跨设备个人历史同步、Mobile 统计页、token 估算、成功安装回执或排名反作弊。真实键盘激活、替代字号档位和所有语言的实机布局未验证;零/缺失/大整数及无作者以定向测试覆盖。插件基座变更仍需指定放行人明确 Approve;CI/独立 review/评分未完成前不能宣称可合并。++原 [方案草案](plugin-usage-statistics-plan.md) 仅作历史设计参考;其安装回执、任务列表和接口建议不作为当前实现事实。